From efe97b0399f59d410ef61ab432fdfb4b63dd6b3e Mon Sep 17 00:00:00 2001 From: Pablo Collins Date: Mon, 25 Nov 2024 15:50:49 -0500 Subject: [PATCH] Set OTEL_TRACES_SAMPLER to always on (#552) * Add host detector * Lint * Remove Telemetry type * Set default sampler * Update release notes * Lint * Fix test --- RELEASE_NOTES.md | 27 ++++++++++++++------------- src/splunk_otel/env.py | 1 + tests/ott_trace_loop.py | 1 - tests/test_distro.py | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index bc114cd..5f7952f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -19,19 +19,20 @@ Summary of changes between Splunk OTel Python major versions 1 and 2. ## Environment Variables -| Variable | v2 default | v1 -> v2 changes | Description | -|---------------------------------------|------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------| -| SPLUNK_ACCESS_TOKEN | | None | Adds token to requests to enable direct ingest (for skipping the collector) | -| OTEL_METRICS_ENABLED | true | None | Causes metrics to be configured (with an otlp-grpc metric exporter and a SystemMetricInstrumentor) | -| OTEL_METRICS_EXPORTER | otlp | Hard coded in v1, configurable in v2 | Indicates the metrics exporter | -| OTEL_TRACE_ENABLED | true | None | Causes tracing to be configured and instrumentors loaded | -| OTEL_TRACES_EXPORTER | otlp | None | Indicates the traces exporter | -| OTEL_PYTHON_DISABLED_INSTRUMENTATIONS | | None | Disables instrumentations by entrypoint name | -| SPLUNK_PROFILER_ENABLED | false | None | Causes the Splunk profiler to start polling at startup | -| OTEL_SPAN_LINK_COUNT_LIMIT | 1000 | None | Sets the maximum allowed span link count | -| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | 12000 | None | Sets the maximum allowed attribute value size | -| SPLUNK_TRACE_RESPONSE_HEADER_ENABLED | true | None | Causes a ServerTimingReponsePropagator to be configured if true (injects tracecontext headers into HTTP responses) | -| OTEL_EXPERIMENTAL_RESOURCE_DETECTORS | host | Not set in v1 | Causes a host resource detector to be configured to set telemetry attributes | +| Variable | v2 default | v1 -> v2 changes | Description | +|---------------------------------------|------------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------| +| SPLUNK_ACCESS_TOKEN | | None | Adds token to requests to enable direct ingest (for skipping the collector) | +| OTEL_METRICS_ENABLED | true | None | Causes metrics to be configured (with an otlp-grpc metric exporter and a SystemMetricInstrumentor) | +| OTEL_METRICS_EXPORTER | otlp | Hard coded in v1, configurable in v2 | Indicates the metrics exporter | +| OTEL_TRACE_ENABLED | true | None | Causes tracing to be configured and instrumentors loaded | +| OTEL_TRACES_EXPORTER | otlp | None | Indicates the traces exporter | +| OTEL_PYTHON_DISABLED_INSTRUMENTATIONS | | None | Disables instrumentations by entrypoint name | +| SPLUNK_PROFILER_ENABLED | false | None | Causes the Splunk profiler to start polling at startup | +| OTEL_SPAN_LINK_COUNT_LIMIT | 1000 | None | Sets the maximum allowed span link count | +| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | 12000 | None | Sets the maximum allowed attribute value size | +| SPLUNK_TRACE_RESPONSE_HEADER_ENABLED | true | None | Causes a ServerTimingReponsePropagator to be configured if true (injects tracecontext headers into HTTP responses) | +| OTEL_EXPERIMENTAL_RESOURCE_DETECTORS | host | Not set in v1 | Causes a host resource detector to be configured to set telemetry attributes | +| OTEL_TRACES_SAMPLER | always_on | Not set in v1 (took upstream default of parentbased_always_on) | | ## Auto-instrumentation diff --git a/src/splunk_otel/env.py b/src/splunk_otel/env.py index 8b6c6c1..2db0718 100644 --- a/src/splunk_otel/env.py +++ b/src/splunk_otel/env.py @@ -28,6 +28,7 @@ "OTEL_SPAN_LINK_COUNT_LIMIT": "1000", "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT": "12000", "OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "host", + "OTEL_TRACES_SAMPLER": "always_on", } OTEL_TRACE_ENABLED = "OTEL_TRACE_ENABLED" diff --git a/tests/ott_trace_loop.py b/tests/ott_trace_loop.py index f83bbe2..f6faa52 100644 --- a/tests/ott_trace_loop.py +++ b/tests/ott_trace_loop.py @@ -1,5 +1,4 @@ from oteltest.telemetry import count_spans, extract_leaves, get_attribute - from ott_lib import project_path, trace_loop NUM_SPANS = 12 diff --git a/tests/test_distro.py b/tests/test_distro.py index ff3e415..6ba1c1d 100644 --- a/tests/test_distro.py +++ b/tests/test_distro.py @@ -20,7 +20,7 @@ def test_distro_env(): env_store = {} configure_distro(env_store) assert env_store["OTEL_TRACES_EXPORTER"] == "otlp" - assert len(env_store) == 12 + assert len(env_store) == 14 def test_access_token():