Skip to content

Commit 7586edf

Browse files
committed
Tweak cross agent tests
1 parent 75a57f4 commit 7586edf

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

tests/hybridagent_opentelemetry/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
def tracer():
3838
trace_provider = TracerProvider()
3939
trace.set_tracer_provider(trace_provider)
40-
41-
return trace.get_tracer(__name__)
40+
41+
return trace_provider.get_tracer()

tests/hybridagent_opentelemetry/test_hybrid_cross_agent.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ def test_opentelemetry_api_can_record_errors(tracer):
146146
# OpenTelemetry API and New Relic API can inject outbound trace context
147147
@dt_enabled
148148
@validate_transaction_metrics(name="Foo", background_task=True)
149-
@validate_span_events(exact_intrinsics={"name": "External/url1/OtelSpan1/GET"}, expected_intrinsics=("parentId",))
149+
@validate_span_events(exact_intrinsics={"name": "External/url1/Default/GET"}, expected_intrinsics=("parentId",))
150150
@validate_span_events(exact_intrinsics={"name": "External/url2/segment1/GET"}, expected_intrinsics=("parentId",))
151-
@validate_span_events(exact_intrinsics={"name": "External/url3/OtelSpan2/GET"}, expected_intrinsics=("parentId",))
151+
@validate_span_events(exact_intrinsics={"name": "External/url3/Default/GET"}, expected_intrinsics=("parentId",))
152152
@validate_span_events(exact_intrinsics={"name": "External/url4/segment2/GET"}, expected_intrinsics=("parentId",))
153153
def test_opentelemetry_api_and_new_relic_api_can_inject_outbound_trace_context(tracer):
154154
application = application_instance(activate=False)
@@ -159,7 +159,7 @@ def test_opentelemetry_api_and_new_relic_api_can_inject_outbound_trace_context(t
159159
name="OtelSpan1",
160160
kind=otel_api_trace.SpanKind.CLIENT,
161161
attributes={"http.url": "http://url1", "http.method": "GET"},
162-
):
162+
) as span1:
163163
headers = {}
164164
PROPAGATOR.inject(carrier=headers)
165165
_, trace_id, span_id, sampled = headers["traceparent"].split("-")
@@ -172,6 +172,10 @@ def test_opentelemetry_api_and_new_relic_api_can_inject_outbound_trace_context(t
172172

173173
# Correct sampled flag was injected
174174
assert transaction.sampled == (sampled == "01")
175+
176+
# Assert that the span name is correct even though
177+
# ExternalTrace types do not have a name attribute
178+
assert span1.name == "OtelSpan1"
175179

176180
# Reset the distributed trace state for the purposes of this test
177181
transaction._distributed_trace_state = 0
@@ -197,7 +201,7 @@ def test_opentelemetry_api_and_new_relic_api_can_inject_outbound_trace_context(t
197201
name="OtelSpan2",
198202
kind=otel_api_trace.SpanKind.CLIENT,
199203
attributes={"http.url": "http://url3", "http.method": "GET"},
200-
):
204+
) as span2:
201205
headers = []
202206
transaction.insert_distributed_trace_headers(headers)
203207
_, trace_id, span_id, sampled = headers[0][1].split("-")
@@ -211,6 +215,10 @@ def test_opentelemetry_api_and_new_relic_api_can_inject_outbound_trace_context(t
211215
# Correct sampled flag was injected
212216
assert transaction.sampled == (sampled == "01")
213217

218+
# Assert that the span name is correct even though
219+
# ExternalTrace types do not have a name attribute
220+
assert span2.name == "OtelSpan2"
221+
214222
# Reset the distributed trace state for the purposes of this test
215223
transaction._distributed_trace_state = 0
216224

0 commit comments

Comments
 (0)