From 9ea7b9605671bb4bc189534c3e37262c4db50e81 Mon Sep 17 00:00:00 2001 From: Pablo Collins Date: Mon, 25 Nov 2024 15:21:28 -0500 Subject: [PATCH] Add host detector (#551) * Bump upstream otel versions. Remove cryptography library (from v1, not used?) Remove protobuf library (version pin conflicted with upstream) * Fix propagator ott deps * Add host detector * Lint * Remove Telemetry type * Update release notes --- RELEASE_NOTES.md | 25 +++++++++++++------------ src/splunk_otel/env.py | 1 + tests/ott_trace_loop.py | 6 +++++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d38e3a8..bc114cd 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -19,18 +19,19 @@ Summary of changes between Splunk OTel Python major versions 1 and 2. ## Environment Variables -| Variable | 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) | +| 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 | ## Auto-instrumentation diff --git a/src/splunk_otel/env.py b/src/splunk_otel/env.py index 9fee7d2..8b6c6c1 100644 --- a/src/splunk_otel/env.py +++ b/src/splunk_otel/env.py @@ -27,6 +27,7 @@ "OTEL_LINK_ATTRIBUTE_COUNT_LIMIT": "", "OTEL_SPAN_LINK_COUNT_LIMIT": "1000", "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT": "12000", + "OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "host", } OTEL_TRACE_ENABLED = "OTEL_TRACE_ENABLED" diff --git a/tests/ott_trace_loop.py b/tests/ott_trace_loop.py index 84cf9b0..f83bbe2 100644 --- a/tests/ott_trace_loop.py +++ b/tests/ott_trace_loop.py @@ -1,4 +1,5 @@ -from oteltest.telemetry import count_spans +from oteltest.telemetry import count_spans, extract_leaves, get_attribute + from ott_lib import project_path, trace_loop NUM_SPANS = 12 @@ -25,5 +26,8 @@ def on_start(self): def on_stop(self, telemetry, stdout: str, stderr: str, returncode: int) -> None: assert count_spans(telemetry) == NUM_SPANS + attributes = extract_leaves(telemetry, "trace_requests", "pbreq", "resource_spans", "resource", "attributes") + assert get_attribute(attributes, "host.name") + def is_http(self): return False