Configure the Python agent for Splunk Observability Cloud ๐
You can configure the Python agent from the Splunk Distribution of OpenTelemetry Python to suit your instrumentation needs. In most cases, modifying the basic configuration is enough to get started.
The following sections describe all available settings for configuring the Python agent, including options for activating new features that are unique to the Splunk Distribution of OpenTelemetry Python.
General settings ๐
The following settings are specific to the Splunk Distribution of OpenTelemetry Python:
Environment variable |
Description |
---|---|
|
A Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Unset by default. Not required unless you need to send data to the Splunk Observability Cloud ingest endpoint. See Create and manage authentication tokens using Splunk Observability Cloud. |
|
Activates the addition of server trace information to HTTP response headers. For more information, see Server trace information. The default value is |
Trace configuration ๐
The following settings control tracing limits and attributes:
Environment variable |
Description |
---|---|
|
Activates tracer creation and autoinstrumentation. The default value is |
|
Name of the service or application youโre instrumenting. Takes precedence over the service name defined in the |
|
Comma-separated list of resource attributes added to every reported span. For example, |
|
Maximum number of attributes per span. The default value is unlimited. |
|
Maximum number of attributes per event. The default value is unlimited. |
|
Maximum number of attributes per link. The default value is unlimited. |
|
Maximum number of events per span. The default value is unlimited. |
|
Maximum number of links per span. The default value is |
|
Maximum length of strings for attribute values. Values larger than the limit are truncated. The default value is |
Exporters configuration ๐
The following settings control trace exporters and their endpoints:
Environment variable |
Description |
---|---|
|
Trace exporter to use. You can set multiple comma-separated values (for example, |
|
The OTLP endpoint. The default value is |
|
The Jaeger endpoint. The default value is |
The Splunk Distribution of OpenTelemetry Python uses the OTLP gRPC span exporter by default. If youโre still using the Smart Agent (now deprecated), or if you want to send traces directly to the Splunk Observability Cloud ingest endpoint, use the Jaeger exporter.
Propagators configuration ๐
The following settings control trace propagation:
Environment variable |
Description |
---|---|
|
Comma-separated list of propagators you want to use. The default value is |
For backward compatibility with the SignalFx Python Tracing Library, use the b3multi trace propagator:
export OTEL_PROPAGATORS=b3multi
$env:OTEL_PROPAGATORS=b3multi
Server trace information ๐
To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, trace response headers are activated by default. The instrumentation adds the following response headers to HTTP responses:
Access-Control-Expose-Headers: Server-Timing
Server-Timing: traceparent;desc="00-<serverTraceId>-<serverSpanId>-01"
The Server-Timing
header contains the traceId
and spanId
parameters in traceparent
format. For more information, see the Server-Timing and traceparent documentation on the W3C website.
Note
If you need to deactivate trace response headers, set SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
to false
.
Configure the Python agent in your code ๐
If you canโt set environment variables or canโt use splunk-py-trace
for setting configuration values at runtime, define the configuration settings in your code.
The following example shows how all the configuration options you can pass to start_tracing()
as arguments:
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from splunk_otel.tracing import start_tracing
start_tracing(
service_name='my-python-service',
span_exporter_factories=[OTLPSpanExporter],
access_token='',
max_attr_length=1200,
trace_response_header_enabled=True,
resource_attributes={
'service.version': '3.1',
'deployment.environment': 'production',
})