Type to search.

ASGI Middleware

Serverless Observability

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

APM Agent Python Preview

The Elastic APM Python agent enables you to trace the execution of operations in your Python applications, sending performance metrics and errors to the Elastic APM Server.

Availability

  • Preview

    This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Warning

This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.

Incorporating Elastic APM into your ASGI-based project only requires a few easy steps.

Note

Several ASGI frameworks are supported natively. Please check Supported Technologies for more information

Install the Elastic APM agent using pip:

Shell
$ pip install elastic-apm

or add elastic-apm to your project’s requirements.txt file.

To set up the agent, you need to initialize it with appropriate settings.

The settings are configured either via environment variables, or as initialization arguments.

You can find a list of all available settings in the Configuration page.

To set up the APM agent, wrap your ASGI app with the ASGITracingMiddleware:

Python
from elasticapm.contrib.asgi import ASGITracingMiddleware

app = MyGenericASGIApp()

app = ASGITracingMiddleware(app)
  1. depending on framework

Make sure to call elasticapm.set_transaction_name() with an appropriate transaction name in all your routes.

Note

Currently, the agent doesn’t support automatic capturing of exceptions. You can follow progress on this issue on Github.

A list of supported Python versions can be found on our Supported Technologies page.

Note

Elastic APM only supports asyncio when using Python 3.7+