In our last blog, we introduced OpenTelemetry Python v1.0.0 and walked you through instrumenting a Python application and install both the OpenTelemetry API and SDK. In this blog, we’ll show you how to get started with the Splunk Distribution of OpenTelemetry Python— a secure, production-ready, Splunk-supported distribution of the OpenTelemetry project that provides multiple installable packages that automatically instruments your Python application to capture and report distributed traces to Splunk APM (no code changes required!), making it easy to get started with distributed tracing!
This Splunk distribution comes with the following defaults:
If you're currently using the SignalFx Tracing Library for Python please note that it has been depreciated, so please migrate to the Splunk Distribution of OpenTelemetry Python (see Migrate from the SignalFx Tracing Library for Python).
The instrumentation works with Python version 3.6+. Supported libraries are listed here.
🚧 This project is currently in BETA.
If you're still using Python 2, continue using the SignalFx Tracing Library for Python.
First, install the splunk-opentelemetry package, run the bootstrap script and wrap your run command with splk-py-trace.
For example, if the runtime parameters were:
python main.py --port=8000
Then the runtime parameters should be updated to:
$ pip install splunk-opentelemetry
$ splk-py-trace-bootstrap
$ SPLUNK_SERVICE_NAME=my-python-app \
splk-py-trace python main.py --port=8000
Notes:
The service name is the only configuration option that typically needs to be specified. A couple of other configuration options that may need to be changed or set are:
Instrumentation works by patching supported libraries at runtime with the OpenTelemetry API to capture and export trace spans. The library is 100% interoperable with OpenTelemetry Python.
To see the Python instrumentation in action with sample applications, see our examples.
All Configuration Options:
Environment Variable | Config Option | Default Value | Notes |
OTEL_EXPORTER_JAEGER_ENDPOINT | endpoint | http://localhost:9080/v1/trace | The jaeger endpoint to connect to. Currently, only HTTP is supported. |
SPLUNK_SERVICE_NAME | service_name | unnamed-python-service | The service name of this Python application. |
SPLUNK_ACCESS_TOKEN | access_token | The optional organization access token for trace submission requests. | |
SPLUNK_MAX_ATTR_LENGTH | max_attr_length | 1200 | Maximum length of string attribute value in characters. Longer values are truncated. |
OTEL_RESOURCE_ATTRIBUTES | unset | Comma-separated list of resource attributes added to every reported span. Example: key1=val1,key2=val2 | |
OTEL_TRACE_ENABLED | true | Globally enables tracer creation and auto- instrumentation. |
This package exports spans in Jaeger Thrift format over HTTP and supports exporting to the SignalFx Smart Agent, OpenTelemetry collector and directly to SignalFx ingest API. You can use OTEL_EXPORTER_JAEGER_ENDPOINT environment variable to specify an export endpoint. The value must be a full URL including scheme and path.
Smart Agent
This is the default option. You do not need to set any config options if you want to export to the Smart Agent and you are running the agent on the default port (9080). The exporter will default to http://localhost:9080/v1/trace when the environment variable is not specified.
In order to do this, you'll need to enable Jaeger Thrift HTTP receiver on OpenTelemetry Collector and set OTEL_EXPORTER_JAEGER_ENDPOINT to http://localhost:14268/api/traces assuming the collector is reachable via localhost.
In order to send traces directly to SignalFx ingest API, you need to:
For advanced and alternative instructions to get started please see the README here.
Voila! You’re up and running! You can find more information and FAQs on the docs site.
Next in our blog series, we’ll be sharing how to get started with the Splunk Distribution of OpenTelemetry Java and the Splunk Distribution of OpenTelemetry Go. Next up for the project, we’ll be announcing OpenTelemetry Java Script v1.0.0 GA soon. Check back here or the OpenTelemetry blog for updates.
Splunk is a contributor to OpenTelemetry and committed to accelerating the adoption of the project. For more information about Splunk and OpenTelemetry, you can check out our latest OpenTelemetry blog posts.
The Splunk platform removes the barriers between data and action, empowering observability, IT and security teams to ensure their organizations are secure, resilient and innovative.
Founded in 2003, Splunk is a global company — with over 7,500 employees, Splunkers have received over 1,020 patents to date and availability in 21 regions around the world — and offers an open, extensible data platform that supports shared data across any environment so that all teams in an organization can get end-to-end visibility, with context, for every interaction and business process. Build a strong data foundation with Splunk.