{"library":"splunk-opentelemetry","title":"Splunk OpenTelemetry Python","type":"library","description":"The `splunk-opentelemetry` Python distribution provides automatic and manual instrumentation for Python applications, collecting traces, metrics, and logs using OpenTelemetry. It bundles OpenTelemetry SDK and API components, along with exporters and instrumentations specifically configured for Splunk Observability Cloud. The current version is 2.9.0, with regular releases tied to upstream OpenTelemetry Python component updates.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install splunk-opentelemetry"],"cli":{"name":"splunk-py-trace","version":"sh: 1: splunk-py-trace: not found"}},"imports":["from splunk_opentelemetry.instrumentation import SplunkOpenTelemetryConfigurator","from opentelemetry import trace","from opentelemetry import metrics"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://docs.splunk.com/observability","github":"https://github.com/signalfx/splunk-otel-python#readme","docs":"https://github.com/signalfx/splunk-otel-python#readme","changelog":null,"pypi":"https://pypi.org/project/splunk-opentelemetry/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\nfrom opentelemetry import trace\nfrom splunk_opentelemetry.instrumentation import SplunkOpenTelemetryConfigurator\n\n# Set required environment variables for the Splunk OTLP exporter\n# In a real application, these would typically be set in the shell or deployment config.\n# For a local OpenTelemetry Collector (e.g., Splunk Distribution of OpenTelemetry Collector),\n# the endpoint might be http://localhost:4318 for HTTP or http://localhost:4317 for gRPC.\nos.environ['OTEL_SERVICE_NAME'] = os.environ.get('OTEL_SERVICE_NAME', 'my-python-app')\nos.environ['OTEL_EXPORTER_OTLP_ENDPOINT'] = os.environ.get('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318')\nos.environ['SPLUNK_ACCESS_TOKEN'] = os.environ.get('SPLUNK_ACCESS_TOKEN', 'YOUR_SPLUNK_ACCESS_TOKEN') # Only required if sending directly to Splunk HEC\n\n# Configure the OpenTelemetry SDK for Splunk Observability Cloud\n# This initializes the TracerProvider, MeterProvider, and sets up\n# the OTLP exporter with Splunk-specific resource attributes.\n# It reads configuration from environment variables.\nSplunkOpenTelemetryConfigurator().configure()\n\n# Get a tracer configured by the Splunk OpenTelemetry SDK\ntracer = trace.get_tracer(__name__)\n\n# Perform a simple operation within a trace\nwith tracer.start_as_current_span(\"my-quickstart-operation\") as span:\n    print(f\"Starting span: {span.name}\")\n    # Add an attribute to the span\n    span.set_attribute(\"http.method\", \"GET\")\n    span.set_attribute(\"http.url\", \"/api/data\")\n\n    # Simulate some work\n    import time\n    time.sleep(0.1)\n\n    with tracer.start_as_current_span(\"inner-work\") as inner_span:\n        print(f\"  Starting inner span: {inner_span.name}\")\n        inner_span.set_attribute(\"data.size\", 1024)\n        time.sleep(0.05)\n        print(f\"  Finishing inner span: {inner_span.name}\")\n\n    print(f\"Finishing span: {span.name}\")\n\nprint(\"\\nTracing complete. Data should be sent to the configured OTLP endpoint.\")\nprint(\"Ensure an OpenTelemetry Collector or Splunk HEC is listening at the endpoint.\")","lang":"python","description":"This quickstart demonstrates programmatic initialization of the Splunk OpenTelemetry Python SDK and a simple traced operation. Ensure that `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_SERVICE_NAME`, and optionally `SPLUNK_ACCESS_TOKEN` environment variables are set before running, pointing to your OpenTelemetry Collector or Splunk HEC endpoint.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"2.10.1","pypi_latest":"2.10.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5.5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"52.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":6.2,"import_time_s":null,"mem_mb":null,"disk_size":"51M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"56.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.4,"import_time_s":null,"mem_mb":null,"disk_size":"55M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"48.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.4,"import_time_s":null,"mem_mb":null,"disk_size":"46M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"47.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.5,"import_time_s":null,"mem_mb":null,"disk_size":"46M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"52.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"splunk-opentelemetry","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":7,"import_time_s":null,"mem_mb":null,"disk_size":"50M"}]}}