Configure the EDOT Python agent
Serverless Observability Stack EDOT Python
Configure the Elastic Distribution of OpenTelemetry Python (EDOT Python) to send data to Elastic.
Configure the OpenTelemetry SDK through the mechanisms documented on the OpenTelemetry website. EDOT Python is typically configured with OTEL_* environment variables defined by the OpenTelemetry spec. For example:
export OTEL_RESOURCE_ATTRIBUTES=service.name=<app-name>,deployment.environment.name=<env-name>
export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-deployment.ingest.us-west1.gcp.cloud.es.io
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey P....l"
opentelemetry-instrument <command to start your service>
		
	Because the Elastic Distribution of OpenTelemetry Python is an extension of OpenTelemetry Python, it supports both:
- General OpenTelemetry configuration options
- Specific configuration options that are only available in EDOT Python
Serverless Stack EDOT Python
APM Agent Central Configuration lets you configure EDOT Python instances remotely, see Central configuration docs for more details.
To activate central configuration, set the ELASTIC_OTEL_OPAMP_ENDPOINT environment variable to the OpAMP server endpoint.
export ELASTIC_OTEL_OPAMP_ENDPOINT=http://localhost:4320/v1/opamp
		
	To deactivate central configuration, remove the ELASTIC_OTEL_OPAMP_ENDPOINT environment variable and restart the instrumented application.
Serverless Stack EDOT Python
If the OpAMP server is configured to require authentication set the ELASTIC_OTEL_OPAMP_HEADERS environment variable.
export ELASTIC_OTEL_OPAMP_HEADERS="Authorization=ApiKey an_api_key"
		
	You can modify the following settings for EDOT Python through APM Agent Central Configuration:
| Settings | Description | Type | Versions | 
|---|---|---|---|
| Logging level | Configure EDOT Python agent logging level. | Dynamic | Stack EDOT Python | 
| Sampling rate | Configure EDOT Python tracing sampling rate. | Dynamic | Stack EDOT Python | 
Dynamic settings can be changed without having to restart the application.
EDOT Python supports all configuration options listed in the OpenTelemetry General SDK Configuration documentation and OpenTelemetry Python.
Instrument Python logging module to format and forward logs in OTLP format is turned off by default and gated under a configuration environment variable:
export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
		
	Turning this on will make any call to logging.basicConfig from your application a no-op.
EDOT Python uses different defaults than OpenTelemetry Python for the following configuration options:
| Option | EDOT Python default | OpenTelemetry Python default | Notes | 
|---|---|---|---|
| OTEL_EXPERIMENTAL_RESOURCE_DETECTORS | process_runtime,os,otel,telemetry_distro,service_instance,containerid,_gcp,aws_ec2,aws_ecs,aws_elastic_beanstalk,azure_app_service,azure_vm | otel | |
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | DELTA | CUMULATIVE | |
| OTEL_LOG_LEVEL | warn | EDOT Python | |
| OTEL_METRICS_EXEMPLAR_FILTER | always_off | trace_based | |
| OTEL_TRACES_SAMPLER | parentbased_traceidratio | parentbased_always_on | EDOT Python | 
| OTEL_TRACES_SAMPLER_ARG | 1.0 | EDOT Python | 
OTEL_EXPERIMENTAL_RESOURCE_DETECTORS cloud resource detectors are dynamically set. When running in a Kubernetes Pod it will be set to process_runtime,os,otel,telemetry_distro,service_instance,_gcp,aws_eks.
OTEL_LOG_LEVEL accepts the following levels: trace, debug, info, warn, error, fatal, off.
ELASTIC_OTEL_ options are specific to Elastic and will always live in EDOT Python include the following.
| Option(s) | Default | Description | 
|---|---|---|
| ELASTIC_OTEL_SYSTEM_METRICS_ENABLED | false | When set to true, sends system namespace metrics. | 
LLM instrumentations implement the following configuration options:
| Option | default | description | 
|---|---|---|
| OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT | false | If set to true, enables the capturing of request and response content in the log events outputted by the agent. | 
To prevent logs from being exported, set OTEL_LOGS_EXPORTER to none. However, application logs might still be gathered and exported by the Collector through the filelog receiver.
To prevent application logs from being collected and exported by the Collector, refer to Exclude paths from logs collection.