Install the OpenTelemetry Operator for Kubernetes to automatically inject instrumentation into your deployed applications with minimal code changes.
Once you have a telemetry pipeline in place, you can gather metrics, logs, and traces from your deployed applications by adding automatic instrumentation to your applications.
You can do this with very little code by installing the OpenTelemetry Operator for Kubernetes in your cluster.
Once installed, the Operator will monitor when pods are created and check whether it should sideload automatic instrumentation packages.We consider this approach to be “low-code” because it requires you to access and modify the Kubernetes deployment manifests for your application. This approach also pushes automatic instrumentation into your code base as the application starts, so that trace data can be gathered. Although this is a very minimal amount of change overall and does not require you to directly modify any application code, we differentiate this from “no-code” because it does require that you modify how your applications are deployed on Kubernetes.Supported languages include:
In this example, we want the Operator to add automatic instrumentation to a Go application, so we must include the manager.featureGates configuration line to the command.
If you are working with a different programming language, you can omit this line.
In this example, we use an automatically generated self-signed certificate by setting admissionWebhooks.certManager.enabled to false and admissionWebhooks.autoGenerateCert.enabled to true. We do not recommend that you use this configuration in a production environment, but setting up a cert-manager is outside the scope of this document.
apiVersion: opentelemetry.io/v1alpha1kind: Instrumentationmetadata: name: otel-autoinstrumentationspec: exporter: endpoint: http://$(OTEL_NODE_IP):4317 propagators: - tracecontext - baggage - b3 sampler: type: parentbased_traceidratio argument: "1" 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_NODE_IP):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_NODE_IP):4318 java: image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:2.10.0 env: # Required if endpoint is set to 4317. # Java autoinstrumentation agent v2.0+ uses http/proto by default # See https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/9bbfe7fe4e3f65cb698d6d2320ac87372d5d572f/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/OtlpProtocolPropertiesSupplier.java#L19 - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://$(OTEL_NODE_IP):4318 nodejs: env: # Optional. # We recommend disabling fs automatic instrumentation because # it can be noisy and expensive during startup - name: OTEL_NODE_DISABLED_INSTRUMENTATIONS value: fs
This manifest instructs the Operator to perform the following actions whenever you add annotations to your pods:
Inject instrumentation into your applications
Configure the export to send data to the node’s IP address
Step 4: Add Annotations to Your Application’s Kubernetes Manifest
In the deployment manifest for your application, add the required annotations. These will vary according to programming language.For example, our Go application requires the following annotations. Note where the annotations are located in the manifest:
Report incorrect code
Copy
apiVersion: apps/v1kind: Deploymentmetadata: name: my-go-appspec: replicas: 1 template: metadata: labels: app: my-go-app annotations: # Added Annotations for auto-instrumentation go here - points at the namespace where the instrumentation # manifest is installed and the name of meta.name field in the instrumentation manifest instrumentation.opentelemetry.io/inject-go: "honeycomb/otel-autoinstrumentation" # Go Requires an additional annotation to the path of the binary on the container instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/path/to/my-go-app" spec: serviceAccountName: my-go-app
Each supported programming language requires different annotations:
The next time requests are made to your application, data should start flowing to Honeycomb. Once your applications are sending data, you can explore trace data and gain insights from the Kubernetes attributes that have been attached by the Kubernetes Attributes Processor in your Collector.