Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parametric: validate span sent to agent in otel span context test #2548

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tests/parametric/test_otel_span_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def test_otel_get_span_context(self, test_agent, test_library):
(https://opentelemetry.io/docs/reference/specification/trace/api/#get-context)
"""
with test_library:
with test_library.otel_start_span(name="operation") as parent:
with test_library.otel_start_span(name="op1") as parent:
parent.end_span()
with test_library.otel_start_span(name="operation", parent_id=parent.span_id) as span:
with test_library.otel_start_span(name="op2", parent_id=parent.span_id) as span:
span.end_span()
context = span.span_context()
assert context.get("trace_id") == parent.span_context().get("trace_id")
Expand All @@ -426,6 +426,13 @@ def test_otel_get_span_context(self, test_agent, test_library):
assert context.get("span_id") == "{:016x}".format(int(span.span_id))
assert context.get("trace_flags") == "01"

# compare the values of the span context with the values of the trace sent to the agent
traces = test_agent.wait_for_num_traces(1)
op2, _ = traces[0]
mabdinur marked this conversation as resolved.
Show resolved Hide resolved
assert op2.get("resource") == "op2"
mabdinur marked this conversation as resolved.
Show resolved Hide resolved
assert op2.get("trace_id") == int(context.get("trace_id"), 16)
mabdinur marked this conversation as resolved.
Show resolved Hide resolved
assert op2.get("span_id") == int(context.get("span_id"), 16)
mabdinur marked this conversation as resolved.
Show resolved Hide resolved

@missing_feature(context.library <= "java@1.23.0", reason="Implemented in 1.24.0")
@missing_feature(context.library == "nodejs", reason="Not implemented")
@missing_feature(context.library <= "dotnet@2.41.0", reason="Implemented in 2.42.0")
Expand Down
Loading