diff --git a/sentry_sdk/integrations/opentelemetry/utils.py b/sentry_sdk/integrations/opentelemetry/utils.py index 51faf41c0c..544362a87c 100644 --- a/sentry_sdk/integrations/opentelemetry/utils.py +++ b/sentry_sdk/integrations/opentelemetry/utils.py @@ -386,22 +386,24 @@ def get_trace_state(span): options = client.options or {} trace_state = trace_state.update( - Baggage.SENTRY_PREFIX + "trace_id", format_trace_id(span_context.trace_id) + Baggage.SENTRY_PREFIX + "trace_id", + quote(format_trace_id(span_context.trace_id)), ) if options.get("environment"): trace_state = trace_state.update( - Baggage.SENTRY_PREFIX + "environment", options["environment"] + Baggage.SENTRY_PREFIX + "environment", quote(options["environment"]) ) if options.get("release"): trace_state = trace_state.update( - Baggage.SENTRY_PREFIX + "release", options["release"] + Baggage.SENTRY_PREFIX + "release", quote(options["release"]) ) if options.get("dsn"): trace_state = trace_state.update( - Baggage.SENTRY_PREFIX + "public_key", Dsn(options["dsn"]).public_key + Baggage.SENTRY_PREFIX + "public_key", + quote(Dsn(options["dsn"]).public_key), ) root_span = get_sentry_meta(span, "root_span") @@ -415,7 +417,7 @@ def get_trace_state(span): and transaction_source not in LOW_QUALITY_TRANSACTION_SOURCES ): trace_state = trace_state.update( - Baggage.SENTRY_PREFIX + "transaction", transaction_name + Baggage.SENTRY_PREFIX + "transaction", quote(transaction_name) ) return trace_state diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index eeea307c9c..fd76c50b50 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -1224,7 +1224,7 @@ def __init__( # OTel timestamps have nanosecond precision start_timestamp = convert_to_otel_timestamp(start_timestamp) - span_name = self._sanitize_name(name or description or op or "") + span_name = name or description or op or "" self._otel_span = tracer.start_span(span_name, start_time=start_timestamp) self.origin = origin or DEFAULT_SPAN_ORIGIN @@ -1598,10 +1598,6 @@ def set_context(self, key, value): self.set_attribute(f"{SentrySpanAttribute.CONTEXT}.{key}", value) - def _sanitize_name(self, name): - """No commas and equals allowed in tracestate.""" - return name.replace(",", "").replace("=", "") - if TYPE_CHECKING: