Enable OpenTelemetry in the Python Agent

Run Splunk AppDynamics APM and the Splunk Distribution of OpenTelemetry in the same Python application process to report data to both platforms.

You can run Python Agent on Splunk AppDynamics and Splunk Distribution of OpenTelemetry in the same application process. This combined mode reports application telemetry to Splunk AppDynamics and Splunk Observability. It also enriches matching OpenTelemetry server spans with AppDynamics Business Transaction context for cross-product correlation.

Install and Enable Combined Agent Mode

Install the OpenTelemetry package extra, select combined deployment mode, and start the Python application with the Python agent.

Combined and OpenTelemetry-only modes require Python 3.10 or higher

  1. Install the Splunk AppDynamics package with the otel extra.
    CODE
    pip install "appdynamics[otel]"
  2. Set the deployment mode to dual.

    Set the APPDYNAMICS_AGENT_DEPLOYMENT_MODE environment variable:

    CODE
    export APPDYNAMICS_AGENT_DEPLOYMENT_MODE=dual

    Alternatively, add the following setting to the appdynamics.cfg file:

    CODE
    [agent]
    deployment-mode = dual
    Following are the available deployment modes:
    Mode Behavior
    appd Runs Splunk AppDynamics only. This mode is the default, so existing deployments are unchanged.
    dual Runs Splunk AppDynamics and Splunk OpenTelemetry together.
    otel Runs Splunk OpenTelemetry only. Python agent and proxy do not start.
    Note: Mode values are case-insensitive, and surrounding whitespace is ignored. An unrecognized value logs a warning and falls back to appd.
  3. Start the application with the Python Agent.
    CODE
    pyagent run -c appdynamics.cfg python <application.py>

The application reports through Splunk AppDynamics and the Splunk Distribution of OpenTelemetry.

Configure the Combined Agent

Review configuration precedence, supplied OpenTelemetry resource values, and included instrumentation.

Use the existing Splunk AppDynamics settings for the Controller connection. Use standard Splunk OpenTelemetry and OpenTelemetry environment variables for authentication, exporters, endpoints, protocols, signals, and resource attributes.

The agent supplies missing OpenTelemetry resource values from Splunk AppDynamics configuration:

Splunk AppDynamics Setting OpenTelemetry Value
Application name service.namespace in OTEL_RESOURCE_ATTRIBUTES
Tier name OTEL_SERVICE_NAME or service.name
Account name deployment.environment.name in OTEL_RESOURCE_ATTRIBUTES

Customer-provided OTEL_SERVICE_NAME, service.namespace, and deployment.environment.name values take precedence and are never overwritten.

Instrumentation

The otel extra includes splunk-opentelemetry==2.11.0 and the following zero-code instrumentation:

  • Web frameworks
    • Flask: opentelemetry-instrumentation-flask
    • Django: opentelemetry-instrumentation-django
    • FastAPI: opentelemetry-instrumentation-fastapi
    • Pyramid: opentelemetry-instrumentation-pyramid
    • Tornado: opentelemetry-instrumentation-tornado
  • HTTP
    • Instrumentation for aiohttp: opentelemetry-instrumentation-aiohttp-client and opentelemetry-instrumentation-aiohttp-server
    • Requests: opentelemetry-instrumentation-requests
    • Instrumentation for urllib3: opentelemetry-instrumentation-urllib3
  • Databases and data stores
    • Instrumentation for psycopg2: opentelemetry-instrumentation-psycopg2
    • PyMySQL: opentelemetry-instrumentation-pymysql
    • MySQL Connector/Python: opentelemetry-instrumentation-mysql
    • Instrumentation for mysqlclient: opentelemetry-instrumentation-mysqlclient
    • Redis: opentelemetry-instrumentation-redis
    • PyMongo: opentelemetry-instrumentation-pymongo

Logging and system-metrics support are supplied by the Splunk distribution. Instrumentation activates automatically, so you do not need to run the opentelemetry-bootstrap command.

Correlation and Resiliency

In the combined (dual) mode, matching OpenTelemetry server spans receive the appd.bt.name, appd.tier.name, appd.app.name, and appd.request.guid attributes. OpenTelemetry trace IDs are also recorded with AppDynamics snapshots, including asynchronous transactions.

The agents start independently. If OpenTelemetry cannot initialize, Splunk AppDynamics continues to run. If AppDynamics cannot initialize, OpenTelemetry continues to run. Initialization problems are recorded in the Python Agent log.

(Optional) Install the Combined Agent Offline

Install the Splunk AppDynamics Python Agent and its Splunk OpenTelemetry dependencies from a download-portal archive.

Download and extract the appropriate download-portal archive. For an Alpine bundle, use musl 1.2 or higher, available with Alpine 3.16 or higher.

Download-portal archives include the complete Splunk OpenTelemetry dependency set.

  1. Install the package and its dependencies from the extracted bundle.
    CODE
    pip install --no-index -f <extracted-bundle> "appdynamics[otel]"
    Note: Use the matching appdynamics-alpine, appdynamics-without-jre, or appdynamics-alpine-without-jre package name when applicable. Offline Alpine bundles require musl 1.2 or newer (Alpine 3.16+).
  2. Optional: Replace appdynamics with the matching package name for your archive.

    Use appdynamics-alpine, appdynamics-without-jre, or appdynamics-alpine-without-jre when applicable.

The installer installs the Python Agent and the complete Splunk OpenTelemetry dependency set from local files.