Skip to content

Commit c2d0d56

Browse files
committed
.
1 parent ffb303d commit c2d0d56

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sentry_sdk/integrations/opentelemetry/span_processor.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sentry_sdk
1515
from sentry_sdk.consts import SPANDATA
1616
from sentry_sdk.tracing import DEFAULT_SPAN_ORIGIN
17+
from sentry_sdk.tracing_utils import create_sampling_context
1718
from sentry_sdk.utils import get_current_thread_meta
1819
from sentry_sdk.profiler.continuous_profiler import (
1920
try_autostart_continuous_profiler,
@@ -66,7 +67,7 @@ def on_start(self, span, parent_context=None):
6667
return
6768

6869
self._add_root_span(span, get_current_span(parent_context))
69-
self._start_profile(span)
70+
self._start_profile(span, parent_context)
7071

7172
def on_end(self, span):
7273
# type: (ReadableSpan) -> None
@@ -105,8 +106,8 @@ def _add_root_span(self, span, parent_span):
105106
# root span points to itself
106107
set_sentry_meta(span, "root_span", span)
107108

108-
def _start_profile(self, span):
109-
# type: (Span) -> None
109+
def _start_profile(self, span, parent_context):
110+
# type: (Span, Optional[Context]) -> None
110111
try_autostart_continuous_profiler()
111112
profiler_id = get_profiler_id()
112113
thread_id, thread_name = get_current_thread_meta()
@@ -126,8 +127,10 @@ def _start_profile(self, span):
126127
# unix timestamp that is on span.start_time
127128
# setting it to 0 means the profiler will internally measure time on start
128129
profile = Profile(sampled, 0)
129-
# TODO-neel-potel sampling context??
130-
profile._set_initial_sampling_decision(sampling_context={})
130+
sampling_context = create_sampling_context(
131+
span.name, span.attributes, parent_context, span.context.trace_id
132+
)
133+
profile._set_initial_sampling_decision(sampling_context)
131134
profile.__enter__()
132135
set_sentry_meta(span, "profile", profile)
133136

0 commit comments

Comments
 (0)