Skip to content

Commit cb66f71

Browse files
nik13claude
andcommitted
test(strands): check header values, not just names, before skipping (TH-8727)
Restore a case where both exporters send the same header names with different values (other keys): Strands' exporter must still be added. A check that compared header names alone passed every test after b1bbf5a. The class docstring and the core 1.1.1 CHANGELOG now describe the exact rule: same traces URL and exactly the same header names and values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Nikhil Pareek <[email protected]>
1 parent b1bbf5a commit cb66f71

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎python/CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
behaviour (for example traceai-strands with `OTEL_EXPORTER_OTLP_*` set to the
2020
Future AGI endpoint), remove it, or every span arrives twice. traceai-strands
2121
0.1.1 does not add its exporter when it would send the same spans to the same
22-
traces URL with no header `register()`'s exporter does not already send.
22+
traces URL with exactly the same header names and values as `register()`'s
23+
exporter; an extra or different header on either side keeps it.
2324
- Not changed: a `TracerProvider()` constructed directly still replaces the default
2425
`SimpleSpanProcessor` added on construction on its first `add_span_processor()`
2526
call.

‎python/frameworks/strands/tests/test_instrumentor.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ class TestStrandsOtlpExporterIsNotDoubled:
296296
OTEL_EXPORTER_OTLP_* at Future AGI as well used to add a second exporter for the same
297297
collector, so every span arrived twice once fi-instrumentation-otel stopped dropping
298298
register()'s exporter on add_span_processor() (TH-8727). The exporter is skipped only for the
299-
same traces URL, with no header the provider's exporter does not already send, and only when
300-
the provider keeps its exporter on the next add_span_processor() call.
299+
same traces URL, with exactly the same header names and values on both exporters, and only
300+
when the provider keeps its exporter on the next add_span_processor() call.
301301
"""
302302

303303
_ENV = (
@@ -499,6 +499,20 @@ def test_added_when_either_side_has_an_extra_header(
499499

500500
assert _RecordingStrandsTelemetry.calls == ["otlp"]
501501

502+
def test_added_when_it_sends_other_values_for_the_same_names(self, monkeypatch):
503+
# Same header names, other keys: the two exporters authenticate as different projects or
504+
# tenants, so Strands' exporter is not a duplicate. Comparing names alone would skip it.
505+
monkeypatch.setenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", _FUTURE_AGI)
506+
monkeypatch.setenv(
507+
"OTEL_EXPORTER_OTLP_TRACES_HEADERS", "X-Api-Key=other-key,X-Secret-Key=other-secret"
508+
)
509+
510+
configure_strands_tracing(
511+
tracer_provider=_provider_exporting_to(_FUTURE_AGI), enable_metrics=False
512+
)
513+
514+
assert _RecordingStrandsTelemetry.calls == ["otlp"]
515+
502516
def test_added_when_project_name_adds_a_header(self, monkeypatch):
503517
# project_name= reaches the backend only as Strands' x-project-name header.
504518
monkeypatch.setenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", _FUTURE_AGI)

0 commit comments

Comments
 (0)