Loading

Set up the EDOT Python agent

Elastic Stack Serverless Observability

Learn how to set up the Elastic Distribution of OpenTelemetry (EDOT) Python in various environments, including Kubernetes and others.

Follow these steps to get started.

  1. Install the distribution

    Install EDOT Python by running pip:

    pip install elastic-opentelemetry
    
  2. Install the available instrumentation

    EDOT Python doesn't install any instrumentation package by default. Instead, it relies on the edot-bootstrap command to scan the installed packages and install the available instrumentation. The following command installs all the instrumentations available for libraries installed in your environment:

    edot-bootstrap --action=install
    
    Note

    Add this command every time you deploy an updated version of your application. Also add it to your container image build process.

  3. Configure EDOT Python

    Refer to Observability quickstart documentation on how to setup your environment.

    To configure EDOT Python you need to set a few OTLP_* environment variables that are available when running EDOT Python:

    • OTEL_RESOURCE_ATTRIBUTES: Use this to add a service.name and deployment.environment. This makes it easier to recognize your application when reviewing data sent to Elastic.

    The following environment variables are not required if you are sending data through a local EDOT Collector but are provided in the Elastic Observability platform onboarding:

    • OTEL_EXPORTER_OTLP_ENDPOINT: The full URL of the endpoint where data will be sent.
    • OTEL_EXPORTER_OTLP_HEADERS: A comma-separated list of key=value pairs that will be added to the headers of every request. This is typically used for authentication information.
  4. Run EDOT Python

    Wrap your service invocation with opentelemetry-instrument, which is the wrapper that provides automatic instrumentation. For example, a web service running with gunicorn might look like this:

    opentelemetry-instrument gunicorn main:app
    
  5. Confirm that EDOT Python is working

    To confirm that EDOT Python has successfully connected to Elastic:

    1. Go to ObservabilityApplicationsService Inventory
    2. Find the name of the service to which you just added EDOT Python. It can take several minutes after initializing EDOT Python for the service to show up in this list.
    3. Select the name in the list to see trace data.
    Note

    There might be no trace data to visualize unless you have invoked your application since initializing EDOT Python.