OpenTelemetry Environment Variables
OpenTelemetry specifies standard environment variables for configuring exporters. These environment variables are supported across multiple programming languages and SDKs.
The most relevant environment variables are:
OTEL_SERVICE_NAME: The name of your application. The service name is used to identify traces, metrics, and logs as explained here.
You can also configure the service name using the
OTEL_RESOURCE_ATTRIBUTES: Additional metadata on the service such as
OTEL_EXPORTER_OTLP_PROTOCOL: Can be
OTEL_EXPORTER_OTLP_ENDPOINT: The endpoint to send the data to.
OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS: Manage Java Resource Providers. (details)
For example, if you run the OpenTelemetry Collector with the OTLP receiver accepting HTTP on localhost port 4318, you can configure your application as follows:
export OTEL_SERVICE_NAME="my-test-application" export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf" export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
If you want to send OpenTelemetry data directly to the Grafana Cloud, you need an additional authorization header with your Grafana instance ID and API key. The authentication header can be set using the
The content of the Authorization header is the base64 encoded string
<instance-id>:<api-key>. See Grafana Cloud docs for how to get your instance ID and API key. Let’s say the base64 encoded data looks like
123456abc123456abc, then you can set the authentication header like this:
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic 123456abc123456abc"