Skip to content

Commit 89e554b

Browse files
committed
Moved set_context to transaction
1 parent c7977d3 commit 89e554b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sentry_sdk/tracing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class Span(object):
9393
"timestamp",
9494
"_tags",
9595
"_data",
96-
"_contexts",
9796
"_span_recorder",
9897
"hub",
9998
"_context_manager_state",
@@ -141,7 +140,6 @@ def __init__(
141140
self.hub = hub
142141
self._tags = {} # type: Dict[str, str]
143142
self._data = {} # type: Dict[str, Any]
144-
self._contexts = {} # type: Dict[str, Any]
145143
self._containing_transaction = containing_transaction
146144
self.start_timestamp = datetime.utcnow()
147145
try:
@@ -470,10 +468,6 @@ def set_http_status(self, http_status):
470468
else:
471469
self.set_status("unknown_error")
472470

473-
def set_context(self, key, value):
474-
# type: (str, Any) -> None
475-
self._contexts[key] = value
476-
477471
def is_success(self):
478472
# type: () -> bool
479473
return self.status == "ok"
@@ -567,6 +561,7 @@ class Transaction(Span):
567561
# tracestate data from other vendors, of the form `dogs=yes,cats=maybe`
568562
"_third_party_tracestate",
569563
"_measurements",
564+
"_contexts",
570565
"_profile",
571566
"_baggage",
572567
"_active_thread_id",
@@ -592,7 +587,9 @@ def __init__(
592587
"instead of Span(transaction=...)."
593588
)
594589
name = kwargs.pop("transaction")
590+
595591
Span.__init__(self, **kwargs)
592+
596593
self.name = name
597594
self.source = source
598595
self.sample_rate = None # type: Optional[float]
@@ -603,6 +600,7 @@ def __init__(
603600
self._sentry_tracestate = sentry_tracestate
604601
self._third_party_tracestate = third_party_tracestate
605602
self._measurements = {} # type: Dict[str, Any]
603+
self._contexts = {} # type: Dict[str, Any]
606604
self._profile = None # type: Optional[sentry_sdk.profiler.Profile]
607605
self._baggage = baggage
608606
# for profiling, we want to know on which thread a transaction is started
@@ -724,6 +722,10 @@ def set_measurement(self, name, value, unit=""):
724722

725723
self._measurements[name] = {"value": value, "unit": unit}
726724

725+
def set_context(self, key, value):
726+
# type: (str, Any) -> None
727+
self._contexts[key] = value
728+
727729
def to_json(self):
728730
# type: () -> Dict[str, Any]
729731
rv = super(Transaction, self).to_json()

0 commit comments

Comments
 (0)