Send Data from Instrumented Code to Collectors

If you’re already using OpenTelemetry, or you’ve decided to instrument your code with OpenTelemetry’s SDKs, you need to tell the SDKs where to send the telemetry data.

Before You Begin 

Before beginning this guide, you should have:

Forward Data from Your Application Code to the Collectors 

Now that you have a telemetry pipeline in your cluster, you must configure the SDKs to forward the telemetry data to your Collectors. To do this, you will use the Kubernetes Downward API, which allows you to pass information about the wider context of your Kubernetes environment into your deployments and therefore your pods. For example, you can use the Downward API to add environment variables that can store pieces of metadata, like the Cluster name.

In our Kubernetes Quick Start, you deployed a DaemonSet-mode Collector listening on the IP address of the node, which is where your SDK must send telemetry data.

  1. Using the Downward API, create an environment variable and pass in the node’s IP address:

      env:
      - name: NODE_IP
        valueFrom:
          fieldRef:
            fieldPath: status.hostIP
    
  2. Configure the node’s environment variable name and value. In this example, we use .NET’s standard environment variable, which is named OTEL_EXPORTER_OTLP_ENDPOINT, and set it to the value of the node’s IP address.

      env:
      - name: NODE_IP
        valueFrom:
          fieldRef:
            fieldPath: status.hostIP
      - name: OTEL_EXPORTER_OTLP_ENDPOINT
        value: http://$(NODE_IP):4317 
    
    Note
    For a list of OTLP exporter configuration options, visit OpenTelemetry’s Protocol Exporter.

After a few minutes, data should start flowing through your observability pipeline and into Honeycomb.