OpenTelemetry Python zero-code instrumentation

Zero-code OpenTelemetry for Python attaches tracing to Django, Flask and FastAPI services through opentelemetry-instrument and environment variables, with logs still in development. This page covers what it does, how to set it up and what to confirm first.

On this page

What OpenTelemetry Python zero-code instrumentation does and when to use it

Zero-code instrumentation lets a Python team collect traces from Django, Flask or FastAPI services without rewriting application code. The entry point is opentelemetry-instrument, a wrapper that runs your existing start command. At startup it loads the OpenTelemetry SDK, reads its settings from environment variables, and patches supported libraries such as web frameworks, HTTP clients and database drivers so that each incoming request and outgoing call produces a span. Your handlers, models and routes stay as they are. This suits a team that needs service-edge traces quickly, before deciding which business spans or attributes are worth adding by hand.

OpenTelemetry is an instrumentation and transport framework, not an observability backend. It generates and exports telemetry, but storage, querying and dashboards are handled by separate tools. The OpenTelemetry Collector sits between the services and those tools: it receives data, processes it and exports it to one or more destinations. Running the Collector as an agent next to services or as a gateway for many sources keeps the Python services pointed at one endpoint, so changing backends later does not require redeploying every application. Confirm the exporter and endpoint variables your chosen Collector deployment expects, and check the Collector configuration guidance before you fix the export path.

Trace APIs and SDKs are stable for Python, which is the part of the zero-code path most teams should plan around. Log SDK maturity varies more across languages and has not reached the same level, so do not assume that zero-code setup also delivers application logs enriched with trace context. Check the OpenTelemetry status page for the current state of the Python logs signal before you scope log work, and confirm which logging library your services use and whether a bridge is supported. Plan tracing first, then treat logs as a separate, verified step.

Configuration options and when each fits

This table compares the environment variable settings that shape a zero-code Python run, from service identity to exporter wiring and sampling. Read each row as a decision: what the setting controls, when it fits a team, and what to check in the configuration reference before you rely on it. Defaults change between releases, so confirm every name and value against the current docs.

SettingWhen it fitsWhat to confirm in the current docs
Service name (OTEL_SERVICE_NAME)Every service, so traces and metrics group under a stable name across deployments and restartsThat the variable name and precedence against resource attributes match your installed version
Resource attributes (OTEL_RESOURCE_ATTRIBUTES)Adding environment, team or version tags that apply to all signals from a Django, Flask or FastAPI processAttribute naming follows the semantic conventions your dashboards expect
Exporter protocol (OTEL_EXPORTER_OTLP_PROTOCOL)Choosing gRPC or HTTP to match what your Collector or backend accepts through your network pathWhich protocols the Python exporter supports for each signal and the expected port for each
Exporter endpoint (OTEL_EXPORTER_OTLP_ENDPOINT)Pointing a host or sidecar at a local Collector, or a central gateway you operateWhether signal-specific endpoint variables override the general one, and the scheme and path required
Exporter headers or TLS settingsSending data to a gateway that requires authentication or an internal certificate authorityHow headers and certificate paths are passed, and where credentials should live rather than in plain config files
Sampler (OTEL_TRACES_SAMPLER)Lowering trace volume on high-traffic web services, or keeping full traces in lower-volume internal appsSampler names, their arguments and whether the parent-based variant is the one you need
Enable or disable instrumentations (OTEL_PYTHON_DISABLED_INSTRUMENTATIONS)Turning off a library integration that creates noisy spans or conflicts with another agentThe exact instrumentation names for your Django, Flask, FastAPI and database libraries
Logs export (OTEL_LOGS_EXPORTER and related settings)Only where your Python log SDK maturity and chosen log pipeline are confirmed to work for your servicesThat the logs signal is still in development for Python, and whether file-based collection is the safer path

Django, Flask and FastAPI: what to check per framework

Django most often runs as a WSGI application behind Gunicorn or uWSGI, and it can also run as an ASGI application under an async server. Zero-code instrumentation wraps the request path, so your first checks are whether each request produces a server span and whether the database work appears beneath it. Start with the framework's routing, because the span name is usually built from the matched URL pattern, and confirm that the name stays a template rather than carrying record IDs or query strings.

  • Request spans: Confirm each request creates a server span with the matched route, and that paths with IDs do not create a new span name for every record.
  • Database coverage: Load a page that runs several ORM queries and confirm the database spans sit under the correct request span, with statements handled as your data policy requires.
  • HTTP client coverage: If the project calls external APIs through requests or urllib3, check for outbound client spans and confirm that trace context reaches the downstream service.
  • Worker model: Under Gunicorn with several workers, confirm every worker exports spans and that service name and resource attributes match across workers.
  • Management commands: Run manage.py migrate and collectstatic under the agent to confirm they finish normally and do not emit noise into production traces.

Check these items on a staging instance that uses the same worker count and start command as production before you change the production configuration.

Setup sequence for a Python service with opentelemetry-instrument

This sequence takes a Python web service from a clean environment to traces arriving at an OpenTelemetry Collector or backend, with no application code changes. Each step ends with a check so the platform team can confirm the result before moving on. The output is an install that can be rebuilt the same way on other hosts.

  1. Create an isolated virtual environment

    The service owner or platform engineer creates a virtual environment on the host or in the container image that runs the service, using the same Python interpreter the application uses in production. Activate it and install the application's own dependencies inside it, so instrumentation is matched to the libraries the service actually imports. Done when the interpreter and pip both resolve to paths inside the environment folder, for example by running which python and python -m pip --version.

  2. Install the distro and OTLP exporter

    Install the distro package, which provides the opentelemetry-instrument launcher and opentelemetry-bootstrap, together with the OTLP exporter that sends data to a Collector or backend. Test the versions first, then pin them in your requirements file, since instrumentation packages track the libraries they wrap. Done when opentelemetry-instrument --help prints usage and pip show opentelemetry-distro returns the version you pinned.

  3. Run bootstrap to install instrumentation

    Run opentelemetry-bootstrap -a requirements to list the instrumentation packages that match the libraries now installed, such as those for Django, Flask, FastAPI, or database and HTTP clients. Review the list before installing so you know which libraries will be instrumented, then run opentelemetry-bootstrap -a install. Commit the resulting packages to your requirements so every build gets the same set. Done when the list includes an instrumentation package for each web framework and client library your service uses.

  4. Set service name and OTLP endpoint

    Set OTEL_SERVICE_NAME to the name your teams use for the service, and set OTEL_EXPORTER_OTLP_ENDPOINT to the address of your Collector agent or gateway. Put these in the deployment manifest or environment file rather than in application code, so the same build runs in every environment. If the Collector runs on another host, confirm its receiver listens on an address the service can reach, since server components bind to localhost by default from Collector v0.110.0 onward, and review the Collector security best practices. Done when env | grep OTEL_ shows both values in the process environment.

  5. Start the service through the launcher

    Start the service by prefixing its normal command with the launcher, for example opentelemetry-instrument python manage.py runserver for Django or opentelemetry-instrument uvicorn main:app for FastAPI. In production, keep the same prefix with your application server and its worker settings, and confirm in the Python instrumentation documentation how your server's worker model works with the launcher before you roll out. Done when the service starts without import errors, answers a test request, and the startup output shows the instrumentation loading.

  6. Verify spans arrive at the Collector

    Send a few requests through the normal request path, then check the Collector's debug output or your backend for spans. Look for the service name you set, span names that use the route template, and child spans for outbound HTTP or database calls. Done when the expected service name appears in traces for each endpoint you exercised. Logs are a separate signal, so check the OpenTelemetry status page for the Python log SDK's maturity before you depend on OTLP log export.

How telemetry flows from a zero-code Python service to the Collector

The flow starts in the Python service process, where the opentelemetry-instrument launcher loads the auto-instrumentation packages and the SDK exports spans and metrics over OTLP. The hand-off that matters is the crossing from the application host into the Collector network, where a Collector runs either as an agent beside the service or as a gateway that accepts data from many sources. The Collector then forwards telemetry to the backend you choose, since OpenTelemetry itself does not store or visualize data. Check that the Collector's receiver and exporter endpoints are reachable only where intended, and that logs follow a separate path because the Python logs signal is still in development.

Zero-code Python telemetry crosses a trust boundary via OTLP into the Collector.

Why the logs signal in Python is still in development

Do not plan on OpenTelemetry carrying your Python application logs to a backend until you have confirmed the current status of the logs signal for Python. The OpenTelemetry status page shows that trace APIs and SDKs are stable in Python, but log SDK maturity varies more by language, and Python's logs support is still marked as in development. The zero-code agent you install with opentelemetry-instrument gives you traces and, depending on the version you pin, metrics, so the log path is the part of the rollout most likely to change between releases. Check the status page for the exact stability level of Python logs on the date you start, and record the version you tested against.

Because the logs signal is not yet a settled choice for Python, most teams keep their existing logging library and make sure each log record carries the trace and span identifiers of the active request. That lets logs and traces be joined in the backend without depending on the OpenTelemetry log exporter. The other common path is file collection, where the application writes structured logs to disk or standard output and the Collector reads them with a log receiver. Each option has different trade-offs in parsing, volume, delivery guarantees and who owns the log format, so decide them with your platform and security teams, and confirm the component stability for any Collector receiver you plan to use in the OpenTelemetry status page.

The detailed setup for injecting trace context into existing logs, choosing between SDK log export and file collection, and checking language support is covered in the sibling topic on correlating logs with traces, so it is not repeated here. For this topic, the practical step is to inventory the logging libraries and handlers your Django, Flask or FastAPI services already use, confirm that your Python version and framework are supported by the instrumentation you chose, and mark which services will keep their current log pipeline until the logs signal is stable enough for your compliance and retention requirements.

Security considerations for Python services and the Collector endpoint

Zero-code instrumentation moves telemetry from every Python process to a Collector, so the risk sits in three places: the environment where service configuration lives, the path telemetry takes out of the process, and the Collector that receives it. The cards below cover the checks that connect those places, and each one is something to verify in your own environment before the first export goes live.

Store environment configuration securely

The opentelemetry-instrument launcher reads its settings from environment variables such as OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME, and those variables often sit in unit files, container specs or CI variables. Move any token or header value into your secrets store and inject it at runtime, so it is never written into a Dockerfile, a Django settings file or a repository. Confirm that process listings and crash dumps on the host do not expose the environment in plain text.

Encrypt and authenticate OTLP exports

Telemetry leaving a Python service can carry user identifiers, query text and error messages, so the export path needs TLS and a sender identity. Point the exporter at an HTTPS endpoint, and where the Collector requires it, have the service present credentials. On the Collector side, authenticator extensions can check incoming connections, for example with OIDC, and attach credentials to outgoing exports. Test the handshake with a non-production service before you rely on it.

Collector configuration docs

Redact sensitive attributes in spans

Zero-code instrumentation records HTTP and database attributes automatically, which can include URL query strings, SQL text and headers. Review what the Python libraries you use put on spans, then use the redaction processor in the Collector to remove or mask keys such as authorization headers, cookies, email addresses and national identifiers before data is exported. Redaction at the Collector is a backstop, so also check which attributes are captured at the source.

Bind receivers to localhost by default

Since Collector v0.110.0, server components bind to localhost by default rather than to all interfaces. Keep that default for a sidecar or agent that only serves local Python processes. When a gateway must accept traffic from other hosts, open the receiver address deliberately, restrict it with network policy or firewall rules, and add authentication. Verify the bound address with your own tooling after each Collector upgrade rather than assuming it.

Collector security best practices

Build Collectors with only needed components

Collector releases ship the contrib distribution with many receivers, processors and exporters, and each extra component is code you must patch and review. Use the Collector Builder to produce a binary that contains only the receivers, processors and exporters your Python services use. Check the signed artifacts, SHA256 checksums and SBOM files that accompany each release before you deploy the build you created.

Collector releases

Restrict who can read service configuration

Anyone who can read the deployment manifest or the process environment of a Python service can often read its telemetry endpoint and any credential passed to it. Limit read access to the service's configuration to the teams that operate it, apply least privilege to Collector configuration files, and audit changes through your version control or deployment system. Ask your platform team which roles can view environment variables in your orchestrator and confirm that answer against the live cluster.

Questions teams ask before running zero-code Python tracing

Can our team set up zero-code Python tracing ourselves?

Often yes, for a small number of services that run on a common framework and a single Collector. The core steps are installing the instrumentation packages with the bootstrap command, starting each service through opentelemetry-instrument, and setting exporter settings through environment variables. Teams usually struggle less with the install than with the parts around it: production process managers, container images, sampling choices, and confirming that each framework and client library they use is covered. If your engineers already run Python services in production and own their deployment pipeline, a pilot on one service is a reasonable first step. Ask whether your team has time to own the rollout across every service, not just the first one.

What makes the effort for Python zero-code tracing grow?

The main drivers are the number of services, the mix of web frameworks and worker models, and how the Collector is designed. Django, Flask and FastAPI each need their own check, and Gunicorn, uWSGI, Celery or background consumers change how the agent must be started and how context moves across processes. Each service adds a deployment target, a container image or virtual environment to update, and a set of environment variables to standardize. Collector design matters because agent, gateway and routing choices determine where telemetry goes and how it is secured. Ask any partner to inventory frameworks, worker models and environments before quoting.

What does our organization need to provide for this work?

You need named owners and access, not only time from engineers. Plan for an environment where the services can be changed and tested, a staging path before production, and someone who can approve changes to each service's startup command or container image. You also need a telemetry backend that can receive traces, such as a self-hosted tool your team already runs, and an owner for it. Security and compliance reviewers should confirm where telemetry is sent and which attributes are captured. Ask for a written list of the systems, accounts and approvals required before the work begins.

How long does Python zero-code tracing take to roll out?

Duration depends on the scope you agree, so the right answer comes from a fixed-scope quote rather than a general rule. The variables are the number of services, how many environments must be covered, how many frameworks and worker models are involved, and how quickly your change approvals and test environments respond. A narrow pilot on one service differs greatly from a rollout across a platform. Ask for a written scope with the services, environments, deliverables and acceptance checks listed, and ask what the plan assumes about your team's availability.

Can the Python logs signal be exported with zero-code instrumentation yet?

Do not assume so. The OpenTelemetry status page lists log SDK maturity by language, and Python's log signal has been documented as still in development, so confirm the current status there before you plan. Teams that need logs correlated with traces usually have options such as keeping existing log files and adding trace and span IDs through a logging bridge, then collecting the files with the Collector. Decide which approach you want before the rollout, and check the current status for the exact version you will run.

When is manual SDK code still needed alongside zero-code tracing?

Zero-code instrumentation covers common library calls such as inbound web requests, database queries and outbound HTTP calls. Manual code is still needed for business-specific spans, attributes that only your application knows, such as an order or account type, and custom spans around internal functions that no library instruments. Manual code also helps when a library is not covered by the instrumentation packages. Keep manual additions small, reviewed and consistent in naming, so they follow the same conventions as the automatic spans. Sensitive values must be kept out of attributes, since the automatic instrumentation may not know what is personal data.

Does zero-code tracing expose sensitive data, and how do we control it?

It can, because automatic instrumentation records request and query details that may include identifiers or personal data depending on the framework. Confirm which attributes each instrumentation package captures, then decide what must be filtered before data leaves the service or the Collector. The OpenTelemetry Collector security guidance recommends using the redaction processor to remove sensitive attributes and securing the Collector configuration with encryption and authentication. Ask any implementation partner to review captured attributes with your security and privacy team before enabling export to shared backends.

How DeployOpen works on this

DeployOpen is a Chainscore Labs company that plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure. For OpenTelemetry Python zero-code instrumentation, we start with a written scope covering your frameworks, environments and Collector endpoints, then build and verify the agent setup in your environment before handover.

How we scope

  • Inventory every Python service, its framework, WSGI or ASGI server, and how each is launched in production.
  • Confirm which hosts can reach the Collector and which network paths, ports and certificates the exporters need.
  • Agree in writing which signals are in scope, with logs flagged as still in development for Python where it applies.

How we build

  • Install the opentelemetry-instrument bootstrap packages in a staging copy of each service and record the resulting dependency set.
  • Set service names, resource attributes and exporter endpoints through environment variables stored in your secrets tooling, not in images.
  • Test trace propagation across service boundaries, check overhead on representative load, and review sensitive attributes before exporting.

How we hand over

  • Deliver a runbook listing each service's launch command, environment variables, pinned package versions and rollback steps.
  • Document the Collector side of the pipeline, including authentication settings and the redaction processor rules applied.
  • Walk your platform and application teams through verification queries and the checklist for adding a new Python service.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Upgrade planning covers bootstrap and instrumentation library versions, with testing before each rollout to production.
  • Re-test instrumentation coverage after framework or Python version changes that your teams plan.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.