Automatic Instrumentation using the OpenTelemetry Operator for Applications in Kubernetes

Last updated on 27 March, 2023

When instrumenting an application in your Kubernetes infrastructure, you can leverage OpenTelemetry’s operator for Kubernetes. This allows you to automatically instrument your application by deploying the operator, defining an instrumentation resource, and then using an annotation to inject that instrumentation for your application containers.

Use OpenTelemetry Operator for Kubernetes from OpenTelemetry along with the following information to use OpenTelemetry’s operator.

Automatically Instrumenting an Application using the OpenTelemetry Operator

  1. Deploy OpenTelemetry’s Operator using Getting Started from OpenTelemetry.
  2. Define a custom instrumentation resource by providing sampling preferences, the LM OTEL Collector endpoint, and resource attributes to map traces to the correct monitored infrastructure in LogicMonitor to create a custom instrumentation resource similar to the following:
kind: Instrumentation


  name: my-instrumentation



  - name: OTEL_POD_IP



        fieldPath: status.podIP


    endpoint: http://mylmotelcollector.endpoint/


    addK8sUIDAttributes: true


{     "resource.type" : "kubernetes-pod",     "ip" : "$(OTEL_POD_ID)"     }


    - tracecontext

    - baggage

    - b3


    type: parentbased_traceidratio

    argument: "0.25"
  1. Apply the pod annotation to pods running applications for automatic instrumentation. This injects the auto instrumentation agent as an init container that downloads the JAR and makes it accessible to the application at startup. For example, you can patch your application deployment using the following:
kubectl patch deployment my-deployment -p '{"spec": {"template":{"metadata":{"annotations":{"":"my-instrumentation"}}}} }'
In This Article