Instrumentation Options
The Instrumentation custom resource provides various configuration options to control how auto-instrumentation is applied to your applications. These options allow you to customize the instrumentation behavior, specify resource requirements, and configure language-specific settings.
Alauda build of OpenTelemetry v2 Operator provides the auto-injection mechanism for instrumentation, but does not include pre-built instrumentation libraries or container images. You need to build your own instrumentation images or use community-provided images.
TOC
Basic Instrumentation ConfigurationInstrumentation CR ParametersDefault Auto-Instrumentation ProtocolsAnnotation-based InjectionLanguage-specific InjectionSDK Variable InjectionSupported Values for Injection AnnotationsNamespace-level InstrumentationResource ConfigurationEnvironment Variable InjectionSelective InstrumentationInstrumentation ReferenceBasic Instrumentation Configuration
The Instrumentation custom resource (CR) defines how telemetry data is collected from your applications. It provides settings for the exporter endpoint, context propagation, sampling, and language-specific instrumentation.
- The exporter endpoint where the Collector receives telemetry data. The default protocol is gRPC on port
4317. - Context propagation formats. Supported values include
tracecontext,baggage,b3,b3multi,jaeger,ottrace, andnone. - The sampler configuration to control the volume of trace data. The
parentbased_traceidratiotype with an argument of0.25means 25% of new root traces are sampled. - Python auto-instrumentation uses
otlp/httpby default. The endpoint must point to the HTTP port4318of the Collector. - .NET auto-instrumentation uses
otlp/httpby default. The endpoint must point to the HTTP port4318of the Collector. - Go auto-instrumentation uses
otlp/httpby default. The endpoint must point to the HTTP port4318of the Collector.
Instrumentation CR Parameters
The following table describes the parameters that can be configured in the Instrumentation custom resource.
Default Auto-Instrumentation Protocols
Each auto-instrumentation language uses a default protocol to export telemetry data to the Collector. The following table lists the default protocols.
You can configure environment variables on the Instrumentation CR. However, after the Operator injects these environment variables into the application container, they cannot be removed by simply updating or deleting the Instrumentation CR. To remove injected environment variables, you must restart or redeploy the affected pods.
Annotation-based Injection
To enable auto-instrumentation for your application, add the appropriate annotation to your pod or namespace:
Language-specific Injection
The annotation format is instrumentation.opentelemetry.io/inject-<language>, where <language> can be:
apache-httpd- For Apache HTTP Serverdotnet- For .NET applicationsgo- For Go applicationsjava- For Java applicationsnodejs- For Node.js applicationspython- For Python applications
SDK Variable Injection
You can use the instrumentation.opentelemetry.io/inject-sdk annotation to instruct the OpenTelemetry Operator to inject SDK environment variables into your pod.
The inject-sdk annotation is useful when you want to inject SDK environment variables without enabling language-specific auto-instrumentation. This is particularly helpful for applications that already include OpenTelemetry SDK dependencies but need centralized configuration management.
Supported Values for Injection Annotations
Namespace-level Instrumentation
You can apply instrumentation to all pods in a namespace by annotating the namespace itself:
Namespace-level annotations provide a convenient way to enable instrumentation for all applications in an environment without modifying individual pod specifications.
Resource Configuration
You can specify resource requests and limits for the instrumentation init container:
Environment Variable Injection
The Instrumentation CR allows you to inject additional environment variables into instrumented containers:
These environment variables are automatically added to the application container when instrumentation is injected.
Selective Instrumentation
You can control which containers in a multi-container pod receive instrumentation by using container-specific annotations:
This annotation ensures that only the specified containers are instrumented, leaving other containers unmodified.
If the container-names annotation is not specified, instrumentation is applied to the first container in the pod by default.
Instrumentation Reference
To reference a specific Instrumentation CR, you can use the full reference format in the annotation:
This allows you to use different instrumentation configurations for different applications within the same namespace.