Agent Configuration
Configuring the agent
The agent is highly configurable, either by:
- Passing it configuration properties from the CLI
- Setting environment variables
Configuration properties
Here’s an example of agent configuration via configuration properties:
opentelemetry-instrument \
--traces_exporter console,otlp \
--metrics_exporter console \
--service_name your-service-name \
--exporter_otlp_endpoint 0.0.0.0:4317 \
python myapp.py
Here’s an explanation of what each configuration does:
traces_exporter
specifies which trace exporter to use. In this case, traces are being exported toconsole
(stdout) and tootlp
. Theotlp
option tellsopentelemetry-instrument
to send it to an endpoint that accepts OTLP via gRPC. The full list of available options for traces_exporter can be found here.otlp
used above fortraces_exporter
is the equivalent of usingotlp_proto_grpc
. To send traces via HTTP instead of gRPC, replaceotlp_proto_grpc
(orotlp
) withotlp_proto_http
.metrics_exporter
specifies which metrics exporter to use. In this case, metrics are being exported toconsole
(stdout). It is currently required for your to specify a metrics exporter. If you aren’t exporting metrics, specifynone
as the value instead.service_name
sets the name of the service associated to the trace, and is sent to your Observability back-end.exporter_otlp_endpoint
tellsopentelemetry-instrument
to send the traces to the given Observability back-end’s endpiont via gRPC, or directly to the OpenTelemetry Collector.exporter_otlp_headers
is required depending on your chosen Observability back-end. More info exporter OTLP headers be found here.If
exporter_otlp_endpoint
is omitted, the agent assumes that you are using the default Collector gRPC endpoint,0.0.0.0:4317
. The above command is the equivalent of saying:opentelemetry-instrument \ --traces_exporter console,otlp_proto_grpc \ --metrics_exporter console\ --service_name your-service-name \ --exporter_otlp_endpoint 0.0.0.0:4317 \ --exporter_otlp_insecure true \ python myapp.py
For HTTP, replace
otlp_proto_grpc
withotlp_proto_http
. If left unspecified, the endpoint is now assumed to be0.0.0.0:4318
(default Collector HTTP endpoint).
Environment Variables
In some cases, configuring via Environment Variables is more preferred. Any setting configurable with a configuration property can also be configured with an Environment Variable.
You can apply the following steps to determine the correct name mapping of the desired configuration property:
- Convert the configuration property to uppercase.
- Prefix environment variable with
OTEL_
For example, exporter_otlp_endpoint
would convert to
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
.
Disabling Specific Instrumentations
The Python agent by default will detect a python program’s packages and
instrument any packages it can.
This makes instrumentation easy, but can result in too much or unwanted data.
You can omit specific packages from instrumentation by using the
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS
environment variable. The environment
variable can be set to a comma-separated list of package names to exclude from
instrumentation.
For example, if your Python program uses the redis
and kafka-python
packages, by default the agent will use the
opentelemetry-instrumentation-redis
and
opentelemetry-instrumentation-kafka-python
packages to instrument them. To
disable this, you can set
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=redis,kafka-python
.