diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 14b6fdfa4c..2038dc4501 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -1186,28 +1186,26 @@ def continue_trace( """ self.generate_propagation_context(environ_or_headers) - # When we generate the propagation context, the sample_rand value is set - # if missing or invalid (we use the original value if it's valid). - # We want the transaction to use the same sample_rand value. Due to duplicated - # propagation logic in the transaction, we pass it in to avoid recomputing it - # in the transaction. - # TYPE SAFETY: self.generate_propagation_context() ensures that self._propagation_context - # is not None. - sample_rand = typing.cast( - PropagationContext, self._propagation_context - )._sample_rand() - - transaction = Transaction.continue_from_headers( - normalize_incoming_data(environ_or_headers), - _sample_rand=sample_rand, + # generate_propagation_context ensures that the propagation_context is not None. + propagation_context = typing.cast(PropagationContext, self._propagation_context) + + optional_kwargs = {} + if name: + optional_kwargs["name"] = name + if source: + optional_kwargs["source"] = source + + return Transaction( op=op, origin=origin, - name=name, - source=source, + baggage=propagation_context.baggage, + parent_sampled=propagation_context.parent_sampled, + trace_id=propagation_context.trace_id, + parent_span_id=propagation_context.parent_span_id, + same_process_as_parent=False, + **optional_kwargs, ) - return transaction - def capture_event(self, event, hint=None, scope=None, **scope_kwargs): # type: (Event, Optional[Hint], Optional[Scope], Any) -> Optional[str] """