Configuration

Configuration methods

Use the environment variables in the tables below to configure the automatic instrumentation binary.

Alternatively, you can add support for additional or different configurations by building your own Go automatic instrumentation binary using the OpenTelemetry Go Automatic Instrumentation package.

Global settings

Environment variableDescriptionDefault value
OTEL_GO_AUTO_TARGET_PIDSets the PID for the Go application to be instrumented. As an alternative to using the environment variable, you can use the -target-pid CLI flag.[^1].Unset
OTEL_GO_AUTO_TARGET_EXESets the binary for the Go application to be instrumented. As an alternative to using the environment variable, you can use the -target-exe CLI flag.[^1].Unset
OTEL_GO_AUTO_GLOBALRecords telemetry from the OpenTelemetry default global implementation. As an alternative to using the environment variable, you can use the -global-impl CLI flag.false
OTEL_LOG_LEVELSets the log level. Supported values: none, error, warn, info, debug. As an alternative to using the environment variable, you can use the -logLevel CLI flag.info

[^1]: One of OTEL_GO_AUTO_TARGET_EXE or OTEL_GO_AUTO_TARGET_PID are required to be set, unless this information is passed directly as CLI arguments.

Resources

Environment variableDescriptionDefault value
OTEL_SERVICE_NAMESets the value of the service.name resource attribute. If service.name is provided in OTEL_RESOURCE_ATTRIBUTES, the value of OTEL_SERVICE_NAME takes precedence.
OTEL_RESOURCE_ATTRIBUTESKey-value pairs to be used as resource attributes. See Resource SDK for details.See Resource semantic conventions for details.
OTEL_GO_AUTO_RESOURCE_DETECTORSComma-separated list of resource detector IDs to enable. See the autodetect package for available detectors IDs and how to register your own.Unset

Instrumentation options

Environment variableDescriptionDefault value
OTEL_GO_AUTO_INCLUDE_DB_STATEMENTSets whether to include SQL queries in the trace data.
OTEL_GO_AUTO_PARSE_DB_STATEMENTSets whether to parse the SQL statement for trace data, setting db.operation.name. Only valid if OTEL_GO_AUTO_INCLUDE_DB_STATEMENT is also set.

Traces exporter

Environment variableDescriptionDefault value
OTEL_TRACES_EXPORTERComma-separated list of propagators. Supported values: otlp, zipkin, console, logging, none. See the OpenTelemetry specification for details.otlp
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMITMaximum allowed attribute value size.No limit
OTEL_SPAN_ATTRIBUTE_COUNT_LIMITMaximum allowed span attribute count.128
OTEL_SPAN_LINK_COUNT_LIMITMaximum allowed span link count.128
OTEL_LINK_ATTRIBUTE_COUNT_LIMITMaximum allowed attribute per span link count.128

OTLP exporter

Environment variableDescriptionDefault value
OTEL_EXPORTER_OTLP_PROTOCOLDefines the OTLP exporter's transport protocol. Supported values: grpc, http/protobuf.http/protobuf
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLDefines the OTLP exporter's transport protocol for the traces signal. Supported values: grpc, http/protobuf. The value of this environment variable takes precedence over OTEL_EXPORTER_OTLP_PROTOCOL.http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINTThe endpoint where the exporter sends the telemetry data. The value must contain a host, and can additionally include a port, scheme, and path. You can use either http or https. The value must not contain a query string or fragment.http/protobuf: https://localhost:4318, grpc: http://localhost:4317
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTThe endpoint where the exporter sends the telemetry data. The value must contain a host, and can additionally include a port, scheme, and path. You can use either http or https. The value must not contain a query string or fragment. The value of this environment variable takes precedence over OTEL_EXPORTER_OTLP_ENDPOINT.http/protobuf: https://localhost:4318/v1/traces, grpc: http://localhost:4317
OTEL_EXPORTER_OTLP_INSECUREDisables client transport security for the exporter's gRPC connection. You can use this only when an endpoint is provided without the http or https scheme.false
OTEL_EXPORTER_OTLP_TRACES_INSECUREDisables client transport security for the exporter's gRPC connection. You can use this only when an endpoint is provided without the http or https scheme. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_INSECURE.false
OTEL_EXPORTER_OTLP_HEADERSKey-value pairs used as gRPC metadata associated with gRPC requests. The value must be represented in a format matching the W3C Baggage HTTP Header Content Format, except that additional semi-colon delimited metadata is not supported. Example value: "key1=value1,key2=value2".Unset
OTEL_EXPORTER_OTLP_TRACES_HEADERSKey-value pairs used as gRPC metadata associated with gRPC requests. The value must be represented in a format matching the W3C Baggage HTTP Header Content Format, except that additional semi-colon delimited metadata is not supported. Example value: "key1=value1,key2=value2". The value of this variable takes precedence over OTEL_EXPORTER_OTLP_HEADERS.Unset
OTEL_EXPORTER_OTLP_TIMEOUTMaximum time in milliseconds the OTLP exporter waits for each batch export.10000
OTEL_EXPORTER_OTLP_TRACES_TIMEOUTMaximum time in milliseconds the OTLP exporter waits for each batch export. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_TIMEOUT.10000
OTEL_EXPORTER_OTLP_COMPRESSIONThe gRPC compressor that the exporter uses. Supported values: gzip, none.Unset
OTEL_EXPORTER_OTLP_TRACES_COMPRESSIONThe gRPC compressor that the exporter uses. Supported values: gzip, none. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_COMPRESSION.Unset
OTEL_EXPORTER_OTLP_CERTIFICATEThe filepath to the trusted certificate to be used when verifying a server's TLS credentials.Unset
OTEL_EXPORTER_OTLP_TRACES_CERTIFICATEThe filepath to the trusted certificate to be used when verifying a server's TLS credentials. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_CERTIFICATE.Unset
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATEThe filepath to the client certificate or chain of trust for the client's private key to use for mTLS communication in the PEM format.Unset
OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATEThe filepath to the client certificate or chain of trust for the client's private key to use for mTLS communication in the PEM format. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE.Unset
OTEL_EXPORTER_OTLP_CLIENT_KEYThe filepath to the client's private key to use for mTLS communication in PEM format.Unset
OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEYThe filepath to the client's private key to use for mTLS communication in PEM format. The value of this variable takes precedence over OTEL_EXPORTER_OTLP_CLIENT_KEY.Unset