Chapter 1. Configuring the instrumentation


The Red Hat build of OpenTelemetry Operator uses an Instrumentation custom resource that defines the configuration of the instrumentation.

1.1. Auto-instrumentation by using libraries

Auto-instrumentation in the Red Hat build of OpenTelemetry Operator can automatically instrument an application without manual code changes. Developers and administrators can monitor applications with minimal effort and changes to the existing codebase.

Important

Auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Auto-instrumentation runs as follows:

  1. The Red Hat build of OpenTelemetry Operator injects an init-container, or a sidecar container for Go, to add the instrumentation libraries for the programming language of the instrumented application.
  2. The Red Hat build of OpenTelemetry Operator sets the required environment variables in the application’s runtime environment. These variables configure the auto-instrumentation libraries to collect traces, metrics, and logs and send them to the appropriate OpenTelemetry Collector or another telemetry backend.
  3. The injected libraries automatically instrument your application by connecting to known frameworks and libraries, such as web servers or database clients, to collect telemetry data. The source code of the instrumented application is not modified.
  4. Once the application is running with the injected instrumentation, the application automatically generates telemetry data, which is sent to a designated OpenTelemetry Collector or an external OTLP endpoint for further processing.

Auto-instrumentation enables you to start collecting telemetry data quickly without having to manually integrate the OpenTelemetry SDK into your application code. However, some applications might require specific configurations or custom manual instrumentation.

The Red Hat build of OpenTelemetry injects and configures the OpenTelemetry auto-instrumentation libraries into your workloads. Currently, the Red Hat build of OpenTelemetry supports injecting instrumentation libraries for Go, Java, Node.js, Python, .NET, and the Apache HTTP Server (httpd).

Important

The Red Hat build of OpenTelemetry Operator only supports the injection mechanism of the instrumentation libraries but does not support instrumentation libraries or upstream images. Customers can build their own instrumentation images or use community images.

1.2.1. Instrumentation options

Instrumentation options are specified in an Instrumentation custom resource (CR).

The following Instrumentation CR example shows instrumentation options:

apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
  name: instrumentation
spec:
  env:
    - name: OTEL_EXPORTER_OTLP_TIMEOUT
      value: "20"
  exporter:
    endpoint: http://production-collector.observability.svc.cluster.local:4317
  propagators:
    - tracecontext
    - baggage
  sampler:
    type: parentbased_traceidratio
    argument: "1"
  python:
    env:
      - name: OTEL_EXPORTER_OTLP_ENDPOINT
        value: http://production-collector.observability.svc.cluster.local:4318
  dotnet:
    env:
      - name: OTEL_EXPORTER_OTLP_ENDPOINT
        value: http://production-collector.observability.svc.cluster.local:4318
  go:
    env:
      - name: OTEL_EXPORTER_OTLP_ENDPOINT
        value: http://production-collector.observability.svc.cluster.local:4318

where:

python
Python auto-instrumentation uses protocol buffers over HTTP (HTTP/proto or HTTP/protobuf) by default.
python.env
Required if endpoint is set to :4317.
dotnet
.NET auto-instrumentation uses protocol buffers over HTTP (HTTP/proto or HTTP/protobuf) by default.
dotnet.env
Required if endpoint is set to :4317.
go
Go auto-instrumentation uses protocol buffers over HTTP (HTTP/proto or HTTP/protobuf) by default.
go.env

Required if endpoint is set to :4317.

For more information about protocol buffers, see Overview (Protocol Buffers Documentation).

The Operator uses the following parameters to define the instrumentation:

ParameterDescriptionValues

env

Definition of common environment variables for all instrumentation types.

 

exporter

Exporter configuration.

 

propagators

Propagators defines inter-process context propagation configuration.

tracecontext, baggage, b3, b3multi, jaeger, ottrace, none

resource

Resource attributes configuration.

 

sampler

Sampling configuration.

 

apacheHttpd

Configuration for the Apache HTTP Server instrumentation.

 

dotnet

Configuration for the .NET instrumentation.

 

go

Configuration for the Go instrumentation.

 

java

Configuration for the Java instrumentation.

 

nodejs

Configuration for the Node.js instrumentation.

 

python

Configuration for the Python instrumentation.

Depending on the programming language, environment variables might not work for configuring telemetry. For the SDKs that do not support environment variable configuration, you must add a similar configuration directly in the code. For more information, see Environment Variable Specification (OpenTelemetry Documentation).

The following protocols are the defaults for auto-instrumentation:

Auto-instrumentationDefault protocol

Java 1.x

otlp/grpc

Java 2.x

otlp/http

Python

otlp/http

.NET

otlp/http

Go

otlp/http

Apache HTTP Server

otlp/grpc

You can use the instrumentation.opentelemetry.io/inject-sdk annotation in the OpenTelemetryCollector custom resource. This annotation instructs the Red Hat build of OpenTelemetry Operator to inject some of the following OpenTelemetry SDK environment variables into your pod, depending on the Instrumentation CR:

  • OTEL_SERVICE_NAME
  • OTEL_TRACES_SAMPLER
  • OTEL_TRACES_SAMPLER_ARG
  • OTEL_PROPAGATORS
  • OTEL_RESOURCE_ATTRIBUTES
  • OTEL_EXPORTER_OTLP_ENDPOINT
  • OTEL_EXPORTER_OTLP_CERTIFICATE
  • OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE
  • OTEL_EXPORTER_OTLP_CLIENT_KEY

The instrumentation.opentelemetry.io/inject-sdk annotation accepts the following values:

ValueDescription

"true"

Injects the Instrumentation resource with the default name from the current namespace.

"false"

Injects no Instrumentation resource.

"<instrumentation_name>"

Specifies the name of the Instrumentation resource to inject from the current namespace.

"<namespace>/<instrumentation_name>"

Specifies the name of the Instrumentation resource to inject from another namespace.

1.2.3. Exporter configuration

Although the Instrumentation custom resource supports setting up one or more exporters per signal, auto-instrumentation configures only the OTLP Exporter. So you must configure the endpoint to point to the OTLP Receiver on the Collector.

The following exporter TLS CA configuration example uses a config map:

apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
# ...
spec:
# ...
  exporter:
    endpoint: https://production-collector.observability.svc.cluster.local:4317
    tls:
      configMapName: ca-bundle
      ca_file: service-ca.crt
# ...

where:

endpoint
Specifies the OTLP endpoint using the HTTPS scheme and TLS.
configMapName
Specifies the name of the config map. The config map must already exist in the namespace of the pod injecting the auto-instrumentation.
ca_file
Points to the CA certificate in the config map or the absolute path to the certificate if the certificate is already present in the workload file system.

The following exporter mTLS configuration example uses a Secret:

apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
# ...
spec:
# ...
  exporter:
    endpoint: https://production-collector.observability.svc.cluster.local:4317
    tls:
      secretName: serving-certs
      ca_file: service-ca.crt
      cert_file: tls.crt
      key_file: tls.key
# ...

where:

endpoint
Specifies the OTLP endpoint by using the HTTPS scheme and TLS.
secretName
Specifies the name of the Secret for the ca_file, cert_file, and key_file values. The Secret must already exist in the namespace of the pod injecting the auto-instrumentation.
ca_file
Points to the CA certificate in the Secret or the absolute path to the certificate if the certificate is already present in the workload file system.
cert_file
Points to the client certificate in the Secret or the absolute path to the certificate if the certificate is already present in the workload file system.
key_file
Points to the client key in the Secret or the absolute path to a key if the key is already present in the workload file system.
Note

You can provide the CA certificate in a config map or Secret. If you provide it in both, the config map takes higher precedence than the Secret.

The following example shows the configuration for CA bundle injection by using a config map and Instrumentation CR:

apiVersion: v1
kind: ConfigMap
metadata:
  name: otelcol-cabundle
  namespace: tutorial-application
  annotations:
    service.beta.openshift.io/inject-cabundle: "true"
# ...
---
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
  name: my-instrumentation
spec:
  exporter:
    endpoint: https://simplest-collector.tracing-system.svc.cluster.local:4317
    tls:
      configMapName: otelcol-cabundle
      ca: service-ca.crt
# ...
Important

The Apache HTTP Server auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

The .spec.apacheHttpd field uses the following parameters:

NameDescriptionDefault

attrs

Attributes specific to the Apache HTTP Server.

 

configPath

Location of the Apache HTTP Server configuration.

/usr/local/apache2/conf

env

Environment variables specific to the Apache HTTP Server.

 

image

Container image with the Apache SDK and auto-instrumentation.

 

resourceRequirements

The compute resource requirements.

 

version

Apache HTTP Server version.

2.4

The following PodSpec annotation enables injection:

instrumentation.opentelemetry.io/inject-apache-httpd: "true"
Important

The .NET auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Important

By default, this feature injects unsupported, upstream instrumentation libraries.

NameDescription

env

Environment variables specific to .NET.

image

Container image with the .NET SDK and auto-instrumentation.

resourceRequirements

The compute resource requirements.

For the .NET auto-instrumentation, the required OTEL_EXPORTER_OTLP_ENDPOINT environment variable must be set if the endpoint of the exporters is set to 4317. The .NET autoinstrumentation uses http/proto by default, and the telemetry data must be set to the 4318 port.

The following PodSpec annotation enables injection:

instrumentation.opentelemetry.io/inject-dotnet: "true"
Important

The Go auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Important

By default, this feature injects unsupported, upstream instrumentation libraries.

NameDescription

env

Environment variables specific to Go.

image

Container image with the Go SDK and auto-instrumentation.

resourceRequirements

The compute resource requirements.

The following PodSpec annotation enables injection:

instrumentation.opentelemetry.io/inject-go: "true"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/<path>/<to>/<container>/<executable>"

where:

otel-go-auto-target-exe
Sets the value for the required OTEL_GO_AUTO_TARGET_EXE environment variable.

Go auto-instrumentation requires the following permissions in the OpenShift cluster:

apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
  name: otel-go-instrumentation-scc
allowHostDirVolumePlugin: true
allowPrivilegeEscalation: true
allowPrivilegedContainer: true
allowedCapabilities:
- "SYS_PTRACE"
fsGroup:
  type: RunAsAny
runAsUser:
  type: RunAsAny
seLinuxContext:
  type: RunAsAny
seccompProfiles:
- '*'
supplementalGroups:
  type: RunAsAny
Tip

The CLI command for applying the permissions for the Go auto-instrumentation in the OpenShift cluster is as follows:

$ oc adm policy add-scc-to-user otel-go-instrumentation-scc -z <service_account>
Important

The Java auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Important

By default, this feature injects unsupported, upstream instrumentation libraries.

NameDescription

env

Environment variables specific to Java.

image

Container image with the Java SDK and auto-instrumentation.

resourceRequirements

The compute resource requirements.

The following PodSpec annotation enables injection:

instrumentation.opentelemetry.io/inject-java: "true"
Important

The Node.js auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Important

By default, this feature injects unsupported, upstream instrumentation libraries.

NameDescription

env

Environment variables specific to Node.js.

image

Container image with the Node.js SDK and auto-instrumentation.

resourceRequirements

The compute resource requirements.

The following PodSpec annotations enable injection:

instrumentation.opentelemetry.io/inject-nodejs: "true"
Important

The Python auto-instrumentation is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Important

By default, this feature injects unsupported, upstream instrumentation libraries.

NameDescription

env

Environment variables specific to Python.

image

Container image with the Python SDK and auto-instrumentation.

resourceRequirements

The compute resource requirements.

For Python auto-instrumentation, the OTEL_EXPORTER_OTLP_ENDPOINT environment variable must be set if the endpoint of the exporters is set to 4317. Python auto-instrumentation uses http/proto by default, and the telemetry data must be set to the 4318 port.

The following PodSpec annotation enables injection:

instrumentation.opentelemetry.io/inject-python: "true"

1.2.10. Multi-container pods

The instrumentation is injected to the first container that is available by default according to the pod specification. You can also specify the target container names for injection.

This pod annotation is required:

instrumentation.opentelemetry.io/container-names: "<container_1>,<container_2>"

where:

container-names
Use this annotation when you want to inject a single instrumentation in multiple containers.
Note

The Go auto-instrumentation does not support multi-container auto-instrumentation injection.

Injecting instrumentation for an application language to one or more containers in a multi-container pod requires the following annotation:

instrumentation.opentelemetry.io/<application_language>-container-names: "<container_1>,<container_2>"

where:

container-names
You can inject instrumentation for only one language per container. For the list of supported <application_language> values, see the following table.

The <application_language> parameter supports the following values:

LanguageValue for <application_language>

ApacheHTTPD

apache-httpd

DotNet

dotnet

Java

java

NGINX

inject-nginx

NodeJS

nodejs

Python

python

SDK

sdk

When using the Instrumentation custom resource (CR) with Red Hat OpenShift Service Mesh, you must use the b3multi propagator.

1.3. Auto-instrumentation by using eBPF

Another auto-instrumentation tool is the zero-code OpenTelemetry eBPF Instrumentation (OBI).

OBI uses the extended Berkeley Packet Filter (eBPF) to automatically instrument supported Linux application executables at the kernel level and the operating system networking layer. OBI can capture trace spans, application metrics, runtime metrics, network metrics, and Rate Errors Duration (RED) metrics.

Important

OBI is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

To implement OBI, use the OBI Receiver.

To collect traces and metrics without instrumenting your application, you can run the OBI Receiver, which uses Linux capabilities.

Prerequisites

  • The OBI Receiver requires nodes that use the amd64 or arm64 CPU architecture. The OBI Receiver is not available on the IBM Z (s390x) or IBM Power (ppc64le) architectures.

Procedure

  1. Apply the service account:

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: obi-collector
      namespace: <namespace>
    # ...
  2. Apply the cluster role:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: obi
    rules:
      - apiGroups: ['apps']
        resources: ['replicasets']
        verbs: ['list', 'watch']
      - apiGroups: ['']
        resources: ['pods', 'services', 'nodes']
        verbs: ['list', 'watch']
  3. Apply the cluster role binding:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: obi
    subjects:
      - kind: ServiceAccount
        name: obi-collector
        namespace: <namespace>
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: obi
  4. Apply the security context constraints:

    apiVersion: security.openshift.io/v1
    kind: SecurityContextConstraints
    metadata:
      name: obi-unprivileged
    allowHostPorts: false
    allowHostDirVolumePlugin: true
    allowHostIPC: false
    allowHostNetwork: false
    allowHostPID: true
    allowPrivilegedContainer: false
    readOnlyRootFilesystem: true
    allowedCapabilities:
      - BPF
      - SYS_PTRACE
      - NET_RAW
      - CHECKPOINT_RESTORE
      - DAC_READ_SEARCH
      - PERFMON
    runAsUser:
      type: RunAsAny
    seLinuxContext:
      type: RunAsAny
    volumes:
      - emptyDir
      - hostPath
      - configMap
      - secret
      - downwardAPI
      - projected
    users:
    - system:serviceaccount:<namespace>:obi-collector
    # ...

    where:

    allowedCapabilities:
    The listed Linux capabilities load the eBPF programs, inspect processes and executables through the /proc filesystem, attach socket filters to capture HTTP requests, and open the Executable and Linkable Format (ELF) files of the instrumented processes.
  5. Apply the OpenTelemetryCollector custom resource:

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: obi-collector
      namespace: <namespace>
    spec:
      mode: daemonset
      serviceAccount: obi-collector
      hostPID: true
      securityContext:
        runAsUser: 0
        readOnlyRootFilesystem: true
        capabilities:
          add:
            - BPF
            - SYS_PTRACE
            - NET_RAW
            - CHECKPOINT_RESTORE
            - DAC_READ_SEARCH
            - PERFMON
          drop:
            - ALL
      volumes:
        - name: var-run-obi
          emptyDir: {}
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
            type: Directory
      volumeMounts:
        - name: var-run-obi
          mountPath: /var/run/obi
        - name: cgroup
          mountPath: /sys/fs/cgroup
          readOnly: true
      config:
        receivers:
          obi:
            discovery:
              instrument:
                - k8s_namespace: <application_namespace>
                  k8s_pod_labels:
                    obi.instrument: "true"
            attributes:
              kubernetes:
                enable: "true"
        exporters:
          debug:
            verbosity: detailed
        service:
          pipelines:
            traces:
              receivers: [obi]
              exporters: [debug]
    # ...

    where:

    hostPID: true
    Enables the OBI Receiver to access the processes on the host.
    discovery.instrument
    Lists the processes the OBI Receiver attaches to. This example filters by namespace and pod labels, so that only pods matching all of the fields are instrumented.
    k8s_namespace: <application_namespace>
    Selects the workloads to instrument.
    attributes.kubernetes.enable
    Setting this field to "true" adds resource attributes such as k8s.namespace.name, k8s.pod.name, and service.name to the traces. Enables Kubernetes attribute enrichment. For enrichment, the Collector ServiceAccount requires the list and watch permissions on pods, services, and nodes in the core API group and on replica sets in the apps API group. These permissions are granted by the ClusterRole in a previous step.
  6. Add the matching label to the workload pod templates to opt them in:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: <application>
      namespace: <application_namespace>
    spec:
      template:
        metadata:
          labels:
            obi.instrument: "true"
        spec:
          containers:
            - name: <application>
              image: <application>:latest
    # ...

Verification

  • The OBI Receiver mounts the host /sys/fs/cgroup directory as read-only so that it can monitor newly created sockets for outgoing requests.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top