Skip to content

Commit e46a07e

Browse files
authored
Merge branch 'master' into ivana/remove-decimal
2 parents 3836e98 + 46eb82c commit e46a07e

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

sentry_sdk/scope.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from typing import TYPE_CHECKING
4949

5050
if TYPE_CHECKING:
51-
from collections.abc import Mapping, MutableMapping
51+
from collections.abc import Mapping
5252

5353
from typing import Any
5454
from typing import Callable
@@ -238,24 +238,24 @@ def __copy__(self):
238238
rv._name = self._name
239239
rv._fingerprint = self._fingerprint
240240
rv._transaction = self._transaction
241-
rv._transaction_info = dict(self._transaction_info)
241+
rv._transaction_info = self._transaction_info.copy()
242242
rv._user = self._user
243243

244-
rv._tags = dict(self._tags)
245-
rv._contexts = dict(self._contexts)
246-
rv._extras = dict(self._extras)
244+
rv._tags = self._tags.copy()
245+
rv._contexts = self._contexts.copy()
246+
rv._extras = self._extras.copy()
247247

248248
rv._breadcrumbs = copy(self._breadcrumbs)
249-
rv._n_breadcrumbs_truncated = copy(self._n_breadcrumbs_truncated)
250-
rv._event_processors = list(self._event_processors)
251-
rv._error_processors = list(self._error_processors)
249+
rv._n_breadcrumbs_truncated = self._n_breadcrumbs_truncated
250+
rv._event_processors = self._event_processors.copy()
251+
rv._error_processors = self._error_processors.copy()
252252
rv._propagation_context = self._propagation_context
253253

254254
rv._should_capture = self._should_capture
255255
rv._span = self._span
256256
rv._session = self._session
257257
rv._force_auto_session_tracking = self._force_auto_session_tracking
258-
rv._attachments = list(self._attachments)
258+
rv._attachments = self._attachments.copy()
259259

260260
rv._profile = self._profile
261261

@@ -683,12 +683,12 @@ def clear(self):
683683
self._level = None # type: Optional[LogLevelStr]
684684
self._fingerprint = None # type: Optional[List[str]]
685685
self._transaction = None # type: Optional[str]
686-
self._transaction_info = {} # type: MutableMapping[str, str]
686+
self._transaction_info = {} # type: dict[str, str]
687687
self._user = None # type: Optional[Dict[str, Any]]
688688

689689
self._tags = {} # type: Dict[str, Any]
690690
self._contexts = {} # type: Dict[str, Dict[str, Any]]
691-
self._extras = {} # type: MutableMapping[str, Any]
691+
self._extras = {} # type: dict[str, Any]
692692
self._attachments = [] # type: List[Attachment]
693693

694694
self.clear_breadcrumbs()

sentry_sdk/tracing.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ class Span:
256256
"""
257257

258258
__slots__ = (
259-
"trace_id",
260-
"span_id",
259+
"_trace_id",
260+
"_span_id",
261261
"parent_span_id",
262262
"same_process_as_parent",
263263
"sampled",
@@ -300,8 +300,8 @@ def __init__(
300300
name=None, # type: Optional[str]
301301
):
302302
# type: (...) -> None
303-
self.trace_id = trace_id or uuid.uuid4().hex
304-
self.span_id = span_id or uuid.uuid4().hex[16:]
303+
self._trace_id = trace_id
304+
self._span_id = span_id
305305
self.parent_span_id = parent_span_id
306306
self.same_process_as_parent = same_process_as_parent
307307
self.sampled = sampled
@@ -355,6 +355,32 @@ def init_span_recorder(self, maxlen):
355355
if self._span_recorder is None:
356356
self._span_recorder = _SpanRecorder(maxlen)
357357

358+
@property
359+
def trace_id(self):
360+
# type: () -> str
361+
if not self._trace_id:
362+
self._trace_id = uuid.uuid4().hex
363+
364+
return self._trace_id
365+
366+
@trace_id.setter
367+
def trace_id(self, value):
368+
# type: (str) -> None
369+
self._trace_id = value
370+
371+
@property
372+
def span_id(self):
373+
# type: () -> str
374+
if not self._span_id:
375+
self._span_id = uuid.uuid4().hex[16:]
376+
377+
return self._span_id
378+
379+
@span_id.setter
380+
def span_id(self, value):
381+
# type: (str) -> None
382+
self._span_id = value
383+
358384
def _get_local_aggregator(self):
359385
# type: (...) -> LocalAggregator
360386
rv = self._local_aggregator

0 commit comments

Comments
 (0)