Registry / observability / autodynatrace

autodynatrace

JSON →
library2.1.1pypypi✓ verified 85d ago

autodynatrace is a Python library that provides automatic instrumentation for applications using the Dynatrace OneAgent SDK. It enables monitoring and tracing for various popular frameworks and libraries like Flask, Django, FastAPI, SQLAlchemy, and aiohttp, typically requiring only a single import at the start of an application. The current version is 2.1.1, with releases occurring as new framework versions or features are supported, often focusing on stability and broader compatibility.

pip install autodynatrace
INSTALL
IMPORT
SIG · AUTODYNATRACE
A
autodynatrace
observabilitypythonv2.1.1
Install
3.1s avg
Import
454ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.478s · 21.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.1s · import 0.429s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

autodynatrace
import autodynatrace
This should be the very first import statement in your application's main entry point file to ensure all supported frameworks and libraries are correctly patched before they initialize.

This quickstart demonstrates a minimal Flask application instrumented with autodynatrace. Ensure the `oneagent-sdk` is also installed. The `import autodynatrace` statement must be the first line of your main application file to ensure proper patching. For asyncio applications, an environment variable is required.

# app.py import os # Must be the first import to ensure all frameworks are patched correctly import autodynatrace from flask import Flask # For asyncio applications (from v2.1.0+), uncomment the line below: # os.environ['AUTODYNATRACE_INSTRUMENT_CONCURRENT'] = 'True' app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, Dynatrace Instrumented World!' if __name__ == '__main__': # To run: # 1. pip install autodynatrace flask oneagent-sdk # 2. python app.py # 3. Access http://localhost:5000 # 4. Check Dynatrace monitoring for traces in your Dynatrace tenant # (Requires OneAgent and SDK configuration) app.run(debug=True, port=5000)
Debug
Known issues
gotchaAutodynatrace relies on the Dynatrace OneAgent SDK for Python (`oneagent-sdk` PyPI package) being installed and properly configured in the environment. Without `oneagent-sdk` present, instrumentation will fail with a `ModuleNotFoundError` or silently not capture data.
fix
Ensure `oneagent-sdk` is installed via `pip install oneagent-sdk` and that your OneAgent is running and configured correctly for your Python environment.
affects: All versions
gotchaFor complete and effective auto-instrumentation, `import autodynatrace` MUST be the very first import statement in your application's main entry point file. Importing it later may result in incomplete or failed instrumentation of certain frameworks or libraries.
fix
Move `import autodynatrace` to the absolute first line of your main application file, before any other imports or code execution.
affects: All versions
breakingVersion 2.1.0 introduced initial support for asyncio. For asyncio applications (e.g., FastAPI, aiohttp), you *must* explicitly set the environment variable `AUTODYNATRACE_INSTRUMENT_CONCURRENT=True` for instrumentation to be active. Asyncio code will not be traced without this setting.
fix
Set the environment variable `AUTODYNATRACE_INSTRUMENT_CONCURRENT=True` before starting your application process (e.g., `export AUTODYNATRACE_INSTRUMENT_CONCURRENT=True` or `os.environ['AUTODYNATRACE_INSTRUMENT_CONCURRENT'] = 'True'` early in your script).
affects: >=2.1.0
gotchaAutodynatrace supports a specific set of frameworks and database drivers (e.g., Flask, Django, FastAPI, SQLAlchemy, Psycopg2). If your application uses an unsupported framework or an unsupported version, instrumentation may not work or may be incomplete.
fix
Refer to the official autodynatrace GitHub README for the list of currently supported frameworks and their versions. Consider upgrading/downgrading dependencies or implementing manual instrumentation if auto-instrumentation is not feasible.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'oneagent'
The Dynatrace OneAgent SDK for Python (`oneagent-sdk` PyPI package), which autodynatrace depends on at runtime, is not installed in the environment.
fix
Install the SDK using pip: `pip install oneagent-sdk`.
My Flask/Django/FastAPI application is running, but no traces or metrics are appearing in Dynatrace.
This typically happens if `autodynatrace` was not imported as the very first statement in your application's entry point, or if the OneAgent itself isn't properly configured/running.
fix
Ensure `import autodynatrace` is the absolute first line of code in your main application file. Also, verify that the Dynatrace OneAgent is installed and configured correctly for your environment (e.g., by ensuring the `DT_ONEAGENT_PYTHON_SDK_PATH` environment variable is set or by running your application within a OneAgent-monitored process).
Asynchronous code (e.g., in FastAPI, aiohttp) is not being traced by Dynatrace when using autodynatrace.
For `autodynatrace` versions 2.1.0 and higher, asyncio instrumentation requires an explicit environment variable to be set.
fix
Set the environment variable `AUTODYNATRACE_INSTRUMENT_CONCURRENT=True` before starting your application. For example: `export AUTODYNATRACE_INSTRUMENT_CONCURRENT=True`.
Upgrade
Version history
2.1.1latest on PyPI · released May 29, 2024
Audit
Dependencies
oneagent-sdkrequiredRequires the Dynatrace OneAgent SDK for Python to be installed and available in the environment for autodynatrace to function. autodynatrace instruments calls to this SDK.
Agent activity
30 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
autodynatrace — pip install autodynatrace · libregistry