Skip to content

Commit

Permalink
fix(opentelemetry): Use dict for sentry-trace context instead of tuple (
Browse files Browse the repository at this point in the history
#1847)

* fix(opentelemetry): Use dict for sentry-trace context instead of tuple
  • Loading branch information
AbhiPrasad authored Jan 19, 2023
1 parent 504188c commit 1ac27c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/opentelemetry/span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _get_trace_data(self, otel_span, parent_context):

sentry_trace_data = get_value(SENTRY_TRACE_KEY, parent_context)
trace_data["parent_sampled"] = (
sentry_trace_data[2] if sentry_trace_data else None
sentry_trace_data["parent_sampled"] if sentry_trace_data else None
)

baggage = get_value(SENTRY_BAGGAGE_KEY, parent_context)
Expand Down
13 changes: 10 additions & 3 deletions tests/integrations/opentelemetry/test_span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from sentry_sdk.tracing import Span, Transaction

from opentelemetry.trace import SpanKind, SpanContext
from sentry_sdk.tracing_utils import extract_sentrytrace_data


def test_is_sentry_span():
Expand Down Expand Up @@ -103,7 +104,9 @@ def test_get_trace_data_with_sentry_trace():
with mock.patch(
"sentry_sdk.integrations.opentelemetry.span_processor.get_value",
side_effect=[
("1234567890abcdef1234567890abcdef", "1234567890abcdef", True),
extract_sentrytrace_data(
"1234567890abcdef1234567890abcdef-1234567890abcdef-1"
),
None,
],
):
Expand All @@ -118,7 +121,9 @@ def test_get_trace_data_with_sentry_trace():
with mock.patch(
"sentry_sdk.integrations.opentelemetry.span_processor.get_value",
side_effect=[
("1234567890abcdef1234567890abcdef", "1234567890abcdef", False),
extract_sentrytrace_data(
"1234567890abcdef1234567890abcdef-1234567890abcdef-0"
),
None,
],
):
Expand Down Expand Up @@ -150,7 +155,9 @@ def test_get_trace_data_with_sentry_trace_and_baggage():
with mock.patch(
"sentry_sdk.integrations.opentelemetry.span_processor.get_value",
side_effect=[
("1234567890abcdef1234567890abcdef", "1234567890abcdef", True),
extract_sentrytrace_data(
"1234567890abcdef1234567890abcdef-1234567890abcdef-1"
),
baggage,
],
):
Expand Down

0 comments on commit 1ac27c8

Please sign in to comment.