The operator can inject and configure OpenTelemetry auto-instrumentation libraries. Currently, Apache HTTPD, DotNet, Go, Java, Nginx, NodeJS and Python are supported.
To use auto-instrumentation, configure an Instrumentation resource with the configuration for the SDK and instrumentation.
kubectl apply -f - <<EOF
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: my-instrumentation
spec:
exporter:
endpoint: http://otel-collector:4317
propagators:
- tracecontext
- baggage
- b3
sampler:
type: parentbased_traceidratio
argument: "0.25"
python:
env:
# Required if endpoint is set to 4317.
# Python autoinstrumentation uses http/proto by default
# so data must be sent to 4318 instead of 4317.
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector:4318
dotnet:
env:
# Required if endpoint is set to 4317.
# Dotnet autoinstrumentation uses http/proto by default
# See https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/888e2cd216c77d12e56b54ee91dafbc4e7452a52/docs/config.md#otlp
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector:4318
go:
env:
# Required if endpoint is set to 4317.
# Go autoinstrumentation uses http/proto by default
# so data must be sent to 4318 instead of 4317.
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector:4318
EOFThe values for propagators are added to the OTEL_PROPAGATORS environment variable.
Valid values for propagators are defined by the OpenTelemetry Specification for OTEL_PROPAGATORS.
The value for sampler.type is added to the OTEL_TRACES_SAMPLER environment variable.
Valid values for sampler.type are defined by the OpenTelemetry Specification for OTEL_TRACES_SAMPLER.
The value for sampler.argument is added to the OTEL_TRACES_SAMPLER_ARG environment variable. Valid values for sampler.argument will depend on the chosen sampler. See the OpenTelemetry Specification for OTEL_TRACES_SAMPLER_ARG for more details.
The instrumentation will automatically inject OTEL_NODE_IP and OTEL_POD_IP environment variables should you need to reference either value in an endpoint.
The above CR can be queried by kubectl get otelinst.
Then add an annotation to a pod to enable injection. The annotation can be added to a namespace, so that all pods within that namespace will get instrumentation, or by adding the annotation to individual PodSpec objects, available as part of Deployment, StatefulSet, and other resources.
The possible values for the annotation can be
"true"- inject andInstrumentationresource from the namespace."my-instrumentation"- name ofInstrumentationCR instance in the current namespace."my-other-namespace/my-instrumentation"- name and namespace ofInstrumentationCR instance in another namespace."false"- do not inject
- Multi-container pods (single instrumentation)
- Instrumenting init containers
- Multi-container pods with multiple instrumentations
- Using customized or vendor instrumentation images
- Configuring resource attributes
See also the API reference.