OpenTelemetry Auto-Instrumentation Configuration ΒΆ

When you enable auto-instrumentation in your application the following OpenTelemetry configuration will become available to your application as environment variables:

VariableExample Value
OTEL_SERVICE_NAMEmy-application
OTEL_EXPORTER_OTLP_ENDPOINThttp://opentelemetry-collector.nais-system:4317
OTEL_EXPORTER_OTLP_PROTOCOLgrpc
OTEL_EXPORTER_OTLP_INSECUREtrue
OTEL_PROPAGATORStracecontext,baggage
OTEL_TRACES_SAMPLERparentbased_always_on
OTEL_LOGS_EXPORTERnone
OTEL_RESOURCE_ATTRIBUTES_POD_NAMEmy-application-777787df6d-pw9mq
OTEL_RESOURCE_ATTRIBUTES_NODE_NAMEgke-node-abc123
OTEL_RESOURCE_ATTRIBUTESservice.name=my-application,service.namespace=my-team,k8s.container.name=my-application,...

Tip

Do not hardcode these values in your application or try to overwrite them in your nais.yaml. OpenTelemetry SDKs and auto-instrumentation libraries will automatically pick up these environment variables and use them to configure the SDK depending on where your application is running.

Extra resource attributes ΒΆ

OpenTelemetry Resource Attributes are key-value pairs that describe the application and its environment. These attributes are attached to all telemetry data produced by the application and must adhere to the OpenTelemetry Semantic Conventions.

Most applications will not need to set extra resource attributes, and only some attributes can be set by the application using the OTEL_RESOURCE_ATTRIBUTES environment variable.

We have compile a list of attributes that can be set by the application and we advise you to consult the specification for more information about how they should be used:

AttributeTypeDescriptionExample ValueStability
deployment.environment.namestringThe version string of the service API or implementation. The format is not defined by these conventions.q1; pexperimental

Sanitizing sensitive data ΒΆ

While the OpenTelemetry SDKs and agends does a best effort to not include any user data, we have added extra protection by redacting some patterns from some trace span attribtes. The following attributes are scrubbed for personal idification numbers (fΓΈdselsnummer):

  • url.path
  • url.full
  • url.original
  • url.query
  • http.url
  • http.target
  • http.route
  • db.statement
  • messaging.kafka.message.key

We advise you to look over the data collected by your application and ensure that no sensitive data is being stored and contact the nais-team if you have any questions or concerns.

Logs auto-instrumentation ΒΆ

You can enable instrumenting logs using the OpenTelemetry Auto-Instrumentation by setting the OTEL_LOGS_EXPORTER environment variable to otlp. This will intercept all logs produced by the application and send them to the OpenTelemetry Collector.

shell

Warning

Enabling logging for the OpenTelemetry Auto-Instrumentation will send all logs to the OpenTelemetry Collector including logs from other libraries and frameworks such as log4j, logback, and slf4j. This should not be enabled if you are using Team Logs.

Agent Versions ΒΆ

The OpenTelemetry Agent is used to automatically instrument your application. The agent is responsible for collecting telemetry data and sending it to the OpenTelemetry Collector.

RuntimeAgent VersionSDK Version
java2.22.01.55.0
nodejs0.67.00.208.0
python0.51b01.30.0
dotnet1.12.0

Java Agent ΒΆ

The OpenTelemetry Java Agent is a Java agent that automatically instruments your Java application. The agent is responsible for collecting telemetry data and sending it to the OpenTelemetry Collector.

It is attached to your JVM automatically at startup using the JAVA_TOOL_OPTIONS environment variable.

Supported libraries, frameworks, application servers, and JVMs ΒΆ

The OpenTelemetry Java Agent supports many popular libraries, frameworks, application servers, and JVMs. A full list of supported libraries and frameworks can be found on the open-telemetry/opentelemetry-java-instrumentation repository.

Advanced Configuration ΒΆ

When using the OpenTelemetry Java SDK and Agent (auto-instrumentation), the following additional environment variables are available:

VariableDescriptionExample Value
OTEL_JAVAAGENT_LOGGINGControles log output from the Java Agent itself, valid values are none, simple, and applicationsimple
OTEL_JAVAAGENT_EXCLUDE_CLASSESSuppresses all instrumentation for specific classes, format is "my.package.MyClass,my.package2.*"my.package.MyClass,my.package2.*
OTEL_INSTRUMENTATION_SPRING_BOOT_ACTUATOR_AUTOCONFIGURE_ENABLEDEnables or disables the Spring Boot Actuator auto-configuration instrumentationfalse
OTEL_INSTRUMENTATION_MICROMETER_ENABLEDEnables or disables the Micrometer instrumentationfalse
OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLEDEnables or disables controller span instrumentationfalse
OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_VIEW_TELEMETRY_ENABLEDEnables or disables view span instrumentationfalse

More OpenTelemetry Configuration ΒΆ

A full list of environment variables that can be used to configure the OpenTelemetry SDK can be found here:

OTLP is the OpenTelemetry Protocol, and is the protocol used to send telemetry data to Prometheus, Grafana Tempo, and Grafana Loki.

Destinations ΒΆ

If you need to override where telemetry data is stored, you can do so with the following configuration in your nais.yaml:

yaml

The following destinations are available:

  • grafana-lgtm

Default destination for each environment can be found in the environments overview.