A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://opentelemetry.io/docs/zero-code/python/configuration below:

Agent Configuration | OpenTelemetry

Agent Configuration

The agent is highly configurable, either by:

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:

Environment Variables

In some cases, configuring via environment variables is more preferred. Any setting configurable with a command-line argument 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:

For example, exporter_otlp_endpoint would convert to OTEL_EXPORTER_OTLP_ENDPOINT.

Python-specific Configuration

There are some Python specific configuration options you can set by prefixing environment variables with OTEL_PYTHON_.

Excluded URLs

Comma-separated regular expressions representing which URLs to exclude across all instrumentations:

You can also exclude URLs for specific instrumentations by using a variable OTEL_PYTHON_<library>_EXCLUDED_URLS, where library is the uppercase version of one of the following: Django, Falcon, FastAPI, Flask, Pyramid, Requests, Starlette, Tornado, urllib, urllib3.

Examples:

export OTEL_PYTHON_EXCLUDED_URLS="client/.*/info,healthcheck"
export OTEL_PYTHON_URLLIB3_EXCLUDED_URLS="client/.*/info"
export OTEL_PYTHON_REQUESTS_EXCLUDED_URLS="healthcheck"
Request Attribute Names

Comma-separated list of names that will be extracted from the request object and set as attributes on spans.

Examples:

export OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS='path_info,content_type'
export OTEL_PYTHON_FALCON_TRACED_REQUEST_ATTRS='query_string,uri_template'
export OTEL_PYTHON_TORNADO_TRACED_REQUEST_ATTRS='uri,query'
Logging

There are some configuration options used to control the logs that are outputted.

Examples:

export OTEL_PYTHON_LOG_CORRELATION=true
export OTEL_PYTHON_LOG_FORMAT="%(msg)s [span_id=%(span_id)s]"
export OTEL_PYTHON_LOG_LEVEL=debug
export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
Other

There are some more configuration options that can be set that don’t fall into a specific category.

Examples:

export OTEL_PYTHON_DJANGO_INSTRUMENT=false
export OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX=my-custom-prefix
export OTEL_PYTHON_GRPC_EXCLUDED_SERVICES="GRPCTestServer,GRPCHealthServer"
export OTEL_PYTHON_ID_GENERATOR=xray
export OTEL_PYTHON_INSTRUMENTATION_SANITIZE_REDIS=true
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 instrumentations entry point names to exclude from instrumentation. Most of the time the entry point name is the same as the package name and it is set in the project.entry-points.opentelemetry_instrumentor table in the package pyproject.toml file.

For example, if your Python program uses the redis,kafka-python and grpc packages, by default the agent will use the opentelemetry-instrumentation-redis, opentelemetry-instrumentation-kafka-python and opentelemetry-instrumentation-grpc packages to instrument them. To disable this, you can set OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=redis,kafka,grpc_client.

Feedback

Was this page helpful?

Thank you. Your feedback is appreciated!

Please let us know how we can improve this page. Your feedback is appreciated!



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4