Skip to content

Commit e7b7109

Browse files
fix tests
1 parent 35f1a76 commit e7b7109

2 files changed

Lines changed: 15 additions & 38 deletions

File tree

tests/test_alignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_span_processor():
170170

171171
def main():
172172
"""Run all tests."""
173-
print("🔍 Testing Kairo Python SDK alignment with .NET SDK...\n")
173+
print("🔍 Testing Agent365 Python SDK alignment with .NET SDK...\n")
174174

175175
try:
176176
test_constants_alignment()

tests/test_baggage_builder.py

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import unittest
66

7-
from microsoft_agents_a365.observability.core import config as telemetry_config
87
from microsoft_agents_a365.observability.core.constants import (
98
CORRELATION_ID_KEY,
109
GEN_AI_AGENT_AUID_KEY,
@@ -104,52 +103,30 @@ def test_all_baggage_keys(self):
104103

105104
def test_baggage_propagates_to_child_spans(self):
106105
"""Test that baggage values are copied as attributes onto parent and child spans via SpanProcessor."""
107-
# Configure global telemetry; this will add the SpanProcessor automatically.
108-
# Use a temporary tracer provider with our in-memory exporter for assertion.
109106
exporter = InMemorySpanExporter()
110107
provider = TracerProvider()
111-
provider.add_span_processor(SimpleSpanProcessor(exporter))
112-
trace.set_tracer_provider(provider)
113-
# Invoke SDK configure to attach Agent365 span processor (agent processor)
114-
telemetry_config.configure(
115-
service_name="baggage-test-service",
116-
service_namespace="baggage.test",
117-
logger_name="Agent365-test",
108+
processor = SimpleSpanProcessor(exporter)
109+
provider.add_span_processor(processor)
110+
111+
# Also add the Agent365 span processor directly
112+
from microsoft_agents_a365.observability.core.trace_processor.span_processor import (
113+
SpanProcessor as Agent365SpanProcessor,
118114
)
119-
tracer = telemetry_config.get_tracer(__name__)
115+
116+
agent365_processor = Agent365SpanProcessor()
117+
provider.add_span_processor(agent365_processor)
118+
119+
tracer = provider.get_tracer(__name__)
120120

121121
tenant = "tenant-propagation-test"
122122
agent = "agent-propagation-test"
123123

124124
# Create baggage before starting spans so processor can copy it
125125
with BaggageBuilder().tenant_id(tenant).agent_id(agent).build():
126-
with tracer.start_as_current_span("parent_span") as parent_span:
127-
# Attributes should now include baggage-derived keys
128-
parent_attrs = getattr(parent_span, "attributes", {})
129-
self.assertEqual(
130-
parent_attrs.get(TENANT_ID_KEY),
131-
tenant,
132-
"Parent span missing tenant attribute from baggage",
133-
)
134-
self.assertEqual(
135-
parent_attrs.get(GEN_AI_AGENT_ID_KEY),
136-
agent,
137-
"Parent span missing agent attribute from baggage",
138-
)
139-
126+
with tracer.start_as_current_span("parent_span"):
140127
# Nested child span should also receive baggage-derived attributes at start
141-
with tracer.start_as_current_span("child_span") as child_span:
142-
child_attrs = getattr(child_span, "attributes", {})
143-
self.assertEqual(
144-
child_attrs.get(TENANT_ID_KEY),
145-
tenant,
146-
"Child span missing tenant attribute from baggage",
147-
)
148-
self.assertEqual(
149-
child_attrs.get(GEN_AI_AGENT_ID_KEY),
150-
agent,
151-
"Child span missing agent attribute from baggage",
152-
)
128+
with tracer.start_as_current_span("child_span"):
129+
pass # Just create the spans, attributes are set by the processor
153130

154131
# Ensure spans exported contain these attributes (export happens on end)
155132
finished_spans = exporter.get_finished_spans()

0 commit comments

Comments
 (0)