Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRD defs for Apache HTTPD Autoinstrumentation #1305

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0abc701
CRD defs for Apache HTTPD Autoinstrumentation
chrlic Dec 6, 2022
c3159fa
Generated resources for Apache Httpd CRD defs
chrlic Dec 6, 2022
232aa55
Generated bundle for Apache Httpd CRD
chrlic Dec 6, 2022
e7f6d15
Fixed version for "make bundle"
chrlic Dec 6, 2022
60fba8f
Makefile and version update
chrlic Dec 6, 2022
7d8ac26
Chngnd repo user to open-telemetry for make bundle
chrlic Dec 6, 2022
7f3355a
Merge branch 'main' into apache-instrumentation-v1.0-crd
chrlic Dec 6, 2022
87126d4
Reverted changes in kustomization.yaml
chrlic Dec 8, 2022
743cce1
Merge branch 'apache-instrumentation-v1.0-crd' of https://github.com/…
chrlic Dec 8, 2022
28a5311
Reverted changes in kustomization.yaml
chrlic Dec 8, 2022
6acaa8e
Reverted chnages in kustomization.yaml
chrlic Dec 8, 2022
3971eff
merge revert
chrlic Dec 8, 2022
9e38814
Merge branch 'open-telemetry:main' into apache-instrumentation-v1.0-crd
chrlic Dec 14, 2022
1108904
Apache HTTPD - Link to attributes doc
chrlic Jan 4, 2023
96e41e1
Merge branch 'apache-instrumentation-v1.0-crd' of https://github.com/…
chrlic Jan 4, 2023
812c27c
Merge branch 'open-telemetry:main' into apache-instrumentation-v1.0-crd
chrlic Jan 4, 2023
1e5c14d
make bundle sync
chrlic Jan 4, 2023
a13cdfe
Merge branch 'apache-instrumentation-v1.0-crd' of https://github.com/…
chrlic Jan 4, 2023
3fa0695
./.chloggen yaml added for #1305
chrlic Jan 4, 2023
28c0229
Version fix
chrlic Jan 4, 2023
9b621e7
Merge branch 'open-telemetry:main' into apache-instrumentation-v1.0-crd
chrlic Jan 5, 2023
0be8dfa
Merge branch 'open-telemetry:main' into apache-instrumentation-v1.0-crd
chrlic Jan 18, 2023
188d382
Merge branch 'open-telemetry:main' into apache-instrumentation-v1.0-crd
chrlic Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/1305-apache-httpd-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: This PR adds CRD for Apache HTTPD auto-instrumentation

# One or more tracking issues related to the change
issues: [1305]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep a
AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-python | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-dotnet | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_APACHE_HTTPD_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-apache-httpd | awk -F= '{print $$2}')"
LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION} -X ${VERSION_PKG}.targetAllocator=${TARGETALLOCATOR_VERSION} -X ${VERSION_PKG}.autoInstrumentationJava=${AUTO_INSTRUMENTATION_JAVA_VERSION} -X ${VERSION_PKG}.autoInstrumentationNodeJS=${AUTO_INSTRUMENTATION_NODEJS_VERSION} -X ${VERSION_PKG}.autoInstrumentationPython=${AUTO_INSTRUMENTATION_PYTHON_VERSION} -X ${VERSION_PKG}.autoInstrumentationDotNet=${AUTO_INSTRUMENTATION_DOTNET_VERSION}"
ARCH ?= $(shell go env GOARCH)

Expand Down
31 changes: 31 additions & 0 deletions apis/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ type InstrumentationSpec struct {
// DotNet defines configuration for DotNet auto-instrumentation.
// +optional
DotNet DotNet `json:"dotnet,omitempty"`

// Apache defines configuration for Apache HTTPD auto-instrumentation.
// +optional
ApacheHttpd ApacheHttpd `json:"apacheHttpd,omitempty"`
}

// Resource defines the configuration for the resource attributes, as defined by the OpenTelemetry specification.
Expand Down Expand Up @@ -145,6 +149,33 @@ type DotNet struct {
Env []corev1.EnvVar `json:"env,omitempty"`
}

type ApacheHttpd struct {
// Image is a container image with Apache SDK and auto-instrumentation.
// +optional
Image string `json:"image,omitempty"`

// Env defines Apache HTTPD specific env vars. There are four layers for env vars' definitions and
// the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
// If the former var had been defined, then the other vars would be ignored.
// +optional
Env []corev1.EnvVar `json:"env,omitempty"`

// Attrs defines Apache HTTPD agent specific attributes. The precedence is:
// `agent default attributes` > `instrument spec attributes` .
// Attributes are documented at https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module
// +optional
Attrs []corev1.EnvVar `json:"attrs,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly is this configuring?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OTel module for Apache httpd has number of configurable attributes (listed at https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module in Configuration section). There are reasonable defaults and some will be set by the instrumentation process, this gives a means to override those defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this link to the godoc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// Apache HTTPD server version. One of 2.4 or 2.2. Default is 2.4
// +optional
Version string `json:"version,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my curiosity how is this version used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apache HTTPD used these days is either version 2.2 or (most of the time) 2.4. The OTel agent is a set of binary loadable modules and those are compiled against specific Apache HTTPD version - different headers etc. Therefore you have to use the specific version of agent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the version setting, auto-instrumentation configures Apache HTTPD with the proper set of modules to be loaded. The docker image with the agent contains modules for both supported versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pavol,
could we move this forward, please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged, thanks ❤️


// Location of Apache HTTPD server configuration.
// Needed only if different from default "/usr/local/apache2/conf"
// +optional
ConfigPath string `json:"configPath,omitempty"`
}

// InstrumentationStatus defines status of the instrumentation.
type InstrumentationStatus struct {
}
Expand Down
27 changes: 21 additions & 6 deletions apis/v1alpha1/instrumentation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ import (
)

const (
AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image"
AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image"
AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image"
AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image"
envPrefix = "OTEL_"
envSplunkPrefix = "SPLUNK_"
AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image"
AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image"
AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image"
AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image"
AnnotationDefaultAutoInstrumentationApacheHttpd = "instrumentation.opentelemetry.io/default-auto-instrumentation-apache-httpd-image"
envPrefix = "OTEL_"
envSplunkPrefix = "SPLUNK_"
)

// log is for logging in this package.
Expand Down Expand Up @@ -78,6 +79,17 @@ func (r *Instrumentation) Default() {
r.Spec.DotNet.Image = val
}
}
if r.Spec.ApacheHttpd.Image == "" {
if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationApacheHttpd]; ok {
r.Spec.ApacheHttpd.Image = val
}
}
if r.Spec.ApacheHttpd.Version == "" {
r.Spec.ApacheHttpd.Version = "2.4"
}
if r.Spec.ApacheHttpd.ConfigPath == "" {
r.Spec.ApacheHttpd.ConfigPath = "/usr/local/apache2/conf"
}
}

// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1
Expand Down Expand Up @@ -134,6 +146,9 @@ func (r *Instrumentation) validate() error {
if err := r.validateEnv(r.Spec.DotNet.Env); err != nil {
return err
}
if err := r.validateEnv(r.Spec.ApacheHttpd.Env); err != nil {
return err
}

return nil
}
Expand Down
10 changes: 6 additions & 4 deletions apis/v1alpha1/instrumentation_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) {
inst := &Instrumentation{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
AnnotationDefaultAutoInstrumentationJava: "java-img:1",
AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1",
AnnotationDefaultAutoInstrumentationPython: "python-img:1",
AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1",
AnnotationDefaultAutoInstrumentationJava: "java-img:1",
AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1",
AnnotationDefaultAutoInstrumentationPython: "python-img:1",
AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1",
AnnotationDefaultAutoInstrumentationApacheHttpd: "apache-httpd-img:1",
},
},
}
Expand All @@ -37,6 +38,7 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) {
assert.Equal(t, "nodejs-img:1", inst.Spec.NodeJS.Image)
assert.Equal(t, "python-img:1", inst.Spec.Python.Image)
assert.Equal(t, "dotnet-img:1", inst.Spec.DotNet.Image)
assert.Equal(t, "apache-httpd-img:1", inst.Spec.ApacheHttpd.Image)
}

func TestInstrumentationValidatingWebhook(t *testing.T) {
Expand Down
30 changes: 30 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading