Skip to content

Commit 2fa3338

Browse files
committed
set attrs later
1 parent bf3f3d1 commit 2fa3338

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

sentry_sdk/_span_batcher.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ def _span_to_transport_format(span):
151151
for (k, v) in span._attributes.items()
152152
}
153153

154-
# We set these as late as possible to increase the odds of the span
155-
# getting a good segment name
156-
res["attributes"]["sentry.segment.id"] = span.containing_transaction.span_id
157-
res["attributes"]["sentry.segment.name"] = span.containing_transaction.name
158-
159154
return res
160155

161156
def _flush(self):

sentry_sdk/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
logger,
2929
get_before_send_log,
3030
get_before_send_metric,
31+
get_default_attributes,
3132
has_logs_enabled,
3233
has_metrics_enabled,
3334
)
@@ -943,6 +944,12 @@ def _capture_span(self, span):
943944
if not has_span_streaming_enabled(self.options):
944945
return
945946

947+
attributes = get_default_attributes()
948+
span._attributes = attributes | span._attributes
949+
950+
span._attributes["sentry.segment.id"] = span.containing_transaction.span_id
951+
span._attributes["sentry.segment.name"] = span.containing_transaction.name
952+
946953
self._span_batcher.add(span)
947954

948955
def _capture_log(self, log):

sentry_sdk/tracing.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
nanosecond_time,
1515
should_be_treated_as_error,
1616
serialize_attribute,
17-
get_default_attributes,
1817
)
1918

2019
from typing import TYPE_CHECKING
@@ -355,11 +354,6 @@ def __init__(
355354

356355
self.update_active_thread()
357356
self.set_profiler_id(get_profiler_id())
358-
self._set_initial_attributes()
359-
360-
def _set_initial_attributes(self):
361-
attributes = get_default_attributes()
362-
self._attributes = attributes | self._attributes
363357

364358
# TODO this should really live on the Transaction class rather than the Span
365359
# class

0 commit comments

Comments
 (0)