|
| 1 | +.. _advanced-python-otel-configuration-1x: |
| 2 | + |
| 3 | +******************************************************************** |
| 4 | +Configure the Python agent for Splunk Observability Cloud |
| 5 | +******************************************************************** |
| 6 | + |
| 7 | +.. meta:: |
| 8 | + :description: Configure the agent of the Splunk Distribution of OpenTelemetry Python to suit most of your instrumentation needs, like correlating traces with logs, activating exporters, and more. |
| 9 | + |
| 10 | +You can configure the Python agent from the Splunk Distribution of OpenTelemetry Python to suit your instrumentation needs. In most cases, modifying the basic configuration is enough to get started. |
| 11 | + |
| 12 | +The following sections describe all available settings for configuring the Python agent, including options for activating new features that are unique to the Splunk Distribution of OpenTelemetry Python. |
| 13 | + |
| 14 | +.. _main-python-agent-settings-1x: |
| 15 | + |
| 16 | +General settings |
| 17 | +========================================================================= |
| 18 | + |
| 19 | +The following settings are specific to the Splunk Distribution of OpenTelemetry Python: |
| 20 | + |
| 21 | +.. list-table:: |
| 22 | + :header-rows: 1 |
| 23 | + |
| 24 | + * - Environment variable |
| 25 | + - Description |
| 26 | + * - ``SPLUNK_ACCESS_TOKEN`` |
| 27 | + - A Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Unset by default. Not required unless you need to send data to the Splunk Observability Cloud ingest endpoint. See :ref:`admin-tokens`. |
| 28 | + * - ``SPLUNK_TRACE_RESPONSE_HEADER_ENABLED`` |
| 29 | + - Activates the addition of server trace information to HTTP response headers. For more information, see :ref:`server-trace-information-python`. The default value is ``true``. |
| 30 | + * - ``OTEL_METRICS_ENABLED`` |
| 31 | + - Activates application metrics collection. The default value is ``true``. See :ref:`python-otel-metrics` for more information. |
| 32 | + |
| 33 | +.. _trace-configuration-python-1x: |
| 34 | + |
| 35 | +Trace configuration |
| 36 | +======================================================= |
| 37 | + |
| 38 | +The following settings control tracing limits and attributes: |
| 39 | + |
| 40 | +.. list-table:: |
| 41 | + :header-rows: 1 |
| 42 | + |
| 43 | + * - Environment variable |
| 44 | + - Description |
| 45 | + * - ``OTEL_TRACE_ENABLED`` |
| 46 | + - Activates tracer creation and autoinstrumentation. The default value is ``true``. |
| 47 | + * - ``OTEL_SERVICE_NAME`` |
| 48 | + - Name of the service or application you're instrumenting. Takes precedence over the service name defined in the ``OTEL_RESOURCE_ATTRIBUTES`` variable. |
| 49 | + * - ``OTEL_RESOURCE_ATTRIBUTES`` |
| 50 | + - Comma-separated list of resource attributes added to every reported span. For example, ``key1=val1,key2=val2``. |
| 51 | + * - ``OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`` |
| 52 | + - Maximum number of attributes per span. The default value is unlimited. |
| 53 | + * - ``OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT`` |
| 54 | + - Maximum number of attributes per event. The default value is unlimited. |
| 55 | + * - ``OTEL_LINK_ATTRIBUTE_COUNT_LIMIT`` |
| 56 | + - Maximum number of attributes per link. The default value is unlimited. |
| 57 | + * - ``OTEL_SPAN_EVENT_COUNT_LIMIT`` |
| 58 | + - Maximum number of events per span. The default value is unlimited. |
| 59 | + * - ``OTEL_SPAN_LINK_COUNT_LIMIT`` |
| 60 | + - Maximum number of links per span. The default value is ``1000``. |
| 61 | + * - ``OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`` |
| 62 | + - Maximum length of strings for attribute values. Values larger than the limit are truncated. The default value is ``1200``. |
| 63 | + |
| 64 | +.. _trace-exporters-settings-python-1x: |
| 65 | + |
| 66 | +Exporters configuration |
| 67 | +=============================================================== |
| 68 | + |
| 69 | +The following settings control trace exporters and their endpoints: |
| 70 | + |
| 71 | +.. list-table:: |
| 72 | + :header-rows: 1 |
| 73 | + |
| 74 | + * - Environment variable |
| 75 | + - Description |
| 76 | + * - ``OTEL_TRACES_EXPORTER`` |
| 77 | + - Trace exporter to use. You can set multiple comma-separated values (for example, ``otlp,console``). The default value is ``otlp``. |
| 78 | + * - ``OTEL_METRICS_EXPORTER`` |
| 79 | + - The metrics exporter to use. The default value is ``otlp``. Accepted values are ``otlp`` and ``none``. Setting ``none`` deactivates metric exports. |
| 80 | + * - ``OTEL_METRIC_EXPORT_INTERVAL`` |
| 81 | + - Interval, in milliseconds, between the start of two export attempts. The default value is ``60000``. |
| 82 | + * - ``OTEL_METRIC_EXPORT_TIMEOUT`` |
| 83 | + - Maximum allowed time to export data, in milliseconds. The default value is ``30000``. |
| 84 | + * - ``OTEL_EXPORTER_OTLP_ENDPOINT`` |
| 85 | + - The OTLP endpoint. The default value is ``http://localhost:4317``. |
| 86 | + * - ``OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`` |
| 87 | + - The OTLP endpoint. The default value is ``http://localhost:4317``. |
| 88 | + |
| 89 | +To send data directly to Splunk Observability Cloud bypassing the Collector, see :ref:`export-directly-to-olly-cloud-python`. |
| 90 | + |
| 91 | +.. _trace-propagation-configuration-python-1x: |
| 92 | + |
| 93 | +Propagators configuration |
| 94 | +======================================================= |
| 95 | + |
| 96 | +The following settings control trace propagation: |
| 97 | + |
| 98 | +.. list-table:: |
| 99 | + :header-rows: 1 |
| 100 | + |
| 101 | + * - Environment variable |
| 102 | + - Description |
| 103 | + * - ``OTEL_PROPAGATORS`` |
| 104 | + - Comma-separated list of propagators you want to use. The default value is ``tracecontext,baggage``. You can find the list of supported propagators in the OpenTelemetry documentation. |
| 105 | + |
| 106 | +For backward compatibility with the SignalFx Python Tracing Library, use the b3multi trace propagator: |
| 107 | + |
| 108 | +.. tabs:: |
| 109 | + |
| 110 | + .. code-tab:: shell Linux |
| 111 | + |
| 112 | + export OTEL_PROPAGATORS=b3multi |
| 113 | + |
| 114 | + .. code-tab:: shell Windows PowerShell |
| 115 | + |
| 116 | + $env:OTEL_PROPAGATORS=b3multi |
| 117 | + |
| 118 | +.. _profiling-configuration-python-1x: |
| 119 | + |
| 120 | +Python settings for AlwaysOn Profiling |
| 121 | +==================================================== |
| 122 | + |
| 123 | +.. note:: Only CPU profiling is supported. |
| 124 | + |
| 125 | +The following settings control the AlwaysOn Profiling feature for the Python agent: |
| 126 | + |
| 127 | +.. list-table:: |
| 128 | + :header-rows: 1 |
| 129 | + :widths: 40, 60 |
| 130 | + |
| 131 | + * - Environment variable |
| 132 | + - Description |
| 133 | + * - ``SPLUNK_PROFILER_ENABLED`` |
| 134 | + - Activates AlwaysOn Profiling. The default value is ``false``. |
| 135 | + * - ``SPLUNK_PROFILER_LOGS_ENDPOINT`` |
| 136 | + - The collector endpoint for profiler logs. By default, it takes the value of ``http://localhost:4317``. |
| 137 | + * - ``SPLUNK_PROFILER_CALL_STACK_INTERVAL`` |
| 138 | + - The frequency of call stack sampling, in milliseconds. The default value is ``1000``. |
| 139 | + * - ``SPLUNK_PROFILER_INCLUDE_INTERNAL_STACKS`` |
| 140 | + - Determines whether to include stack traces from internal profiler threads. The default value is ``false``. |
| 141 | + |
| 142 | +.. _server-trace-information-python-1x: |
| 143 | + |
| 144 | +Server trace information |
| 145 | +============================================== |
| 146 | + |
| 147 | +To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, trace response headers are activated by default. The instrumentation adds the following response headers to HTTP responses: |
| 148 | + |
| 149 | +.. code-block:: |
| 150 | +
|
| 151 | + Access-Control-Expose-Headers: Server-Timing |
| 152 | + Server-Timing: traceparent;desc="00-<serverTraceId>-<serverSpanId>-01" |
| 153 | +
|
| 154 | +The ``Server-Timing`` header contains the ``traceId`` and ``spanId`` parameters in ``traceparent`` format. For more information, see the Server-Timing and traceparent documentation on the W3C website. |
| 155 | + |
| 156 | +.. note:: If you need to deactivate trace response headers, set ``SPLUNK_TRACE_RESPONSE_HEADER_ENABLED`` to ``false``. |
| 157 | + |
| 158 | +.. _code-configuration-python-1x: |
| 159 | + |
| 160 | +Configure the Python agent in your code |
| 161 | +==================================================== |
| 162 | + |
| 163 | +If you can't set environment variables or can't use ``splunk-py-trace`` for setting configuration values at runtime, define the configuration settings in your code. |
| 164 | + |
| 165 | +See :ref:`python-manual-instrumentation` for more information. |
| 166 | + |
0 commit comments