Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49a6d1d

Browse files
authored
Remove name sanitization for POTelSpan and quote trace state populated values (#3705)
1 parent 2c26f42 commit 49a6d1d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

sentry_sdk/integrations/opentelemetry/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,22 +386,24 @@ def get_trace_state(span):
386386
options = client.options or {}
387387

388388
trace_state = trace_state.update(
389-
Baggage.SENTRY_PREFIX + "trace_id", format_trace_id(span_context.trace_id)
389+
Baggage.SENTRY_PREFIX + "trace_id",
390+
quote(format_trace_id(span_context.trace_id)),
390391
)
391392

392393
if options.get("environment"):
393394
trace_state = trace_state.update(
394-
Baggage.SENTRY_PREFIX + "environment", options["environment"]
395+
Baggage.SENTRY_PREFIX + "environment", quote(options["environment"])
395396
)
396397

397398
if options.get("release"):
398399
trace_state = trace_state.update(
399-
Baggage.SENTRY_PREFIX + "release", options["release"]
400+
Baggage.SENTRY_PREFIX + "release", quote(options["release"])
400401
)
401402

402403
if options.get("dsn"):
403404
trace_state = trace_state.update(
404-
Baggage.SENTRY_PREFIX + "public_key", Dsn(options["dsn"]).public_key
405+
Baggage.SENTRY_PREFIX + "public_key",
406+
quote(Dsn(options["dsn"]).public_key),
405407
)
406408

407409
root_span = get_sentry_meta(span, "root_span")
@@ -415,7 +417,7 @@ def get_trace_state(span):
415417
and transaction_source not in LOW_QUALITY_TRANSACTION_SOURCES
416418
):
417419
trace_state = trace_state.update(
418-
Baggage.SENTRY_PREFIX + "transaction", transaction_name
420+
Baggage.SENTRY_PREFIX + "transaction", quote(transaction_name)
419421
)
420422

421423
return trace_state

sentry_sdk/tracing.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ def __init__(
12241224
# OTel timestamps have nanosecond precision
12251225
start_timestamp = convert_to_otel_timestamp(start_timestamp)
12261226

1227-
span_name = self._sanitize_name(name or description or op or "")
1227+
span_name = name or description or op or ""
12281228
self._otel_span = tracer.start_span(span_name, start_time=start_timestamp)
12291229

12301230
self.origin = origin or DEFAULT_SPAN_ORIGIN
@@ -1598,10 +1598,6 @@ def set_context(self, key, value):
15981598

15991599
self.set_attribute(f"{SentrySpanAttribute.CONTEXT}.{key}", value)
16001600

1601-
def _sanitize_name(self, name):
1602-
"""No commas and equals allowed in tracestate."""
1603-
return name.replace(",", "").replace("=", "")
1604-
16051601

16061602
if TYPE_CHECKING:
16071603

0 commit comments

Comments
 (0)