Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Dec 3, 2024
1 parent ffb303d commit c2d0d56
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sentry_sdk/integrations/opentelemetry/span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sentry_sdk
from sentry_sdk.consts import SPANDATA
from sentry_sdk.tracing import DEFAULT_SPAN_ORIGIN
from sentry_sdk.tracing_utils import create_sampling_context
from sentry_sdk.utils import get_current_thread_meta
from sentry_sdk.profiler.continuous_profiler import (
try_autostart_continuous_profiler,
Expand Down Expand Up @@ -66,7 +67,7 @@ def on_start(self, span, parent_context=None):
return

self._add_root_span(span, get_current_span(parent_context))
self._start_profile(span)
self._start_profile(span, parent_context)

def on_end(self, span):
# type: (ReadableSpan) -> None
Expand Down Expand Up @@ -105,8 +106,8 @@ def _add_root_span(self, span, parent_span):
# root span points to itself
set_sentry_meta(span, "root_span", span)

def _start_profile(self, span):
# type: (Span) -> None
def _start_profile(self, span, parent_context):
# type: (Span, Optional[Context]) -> None
try_autostart_continuous_profiler()
profiler_id = get_profiler_id()
thread_id, thread_name = get_current_thread_meta()
Expand All @@ -126,8 +127,10 @@ def _start_profile(self, span):
# unix timestamp that is on span.start_time
# setting it to 0 means the profiler will internally measure time on start
profile = Profile(sampled, 0)
# TODO-neel-potel sampling context??
profile._set_initial_sampling_decision(sampling_context={})
sampling_context = create_sampling_context(
span.name, span.attributes, parent_context, span.context.trace_id
)
profile._set_initial_sampling_decision(sampling_context)
profile.__enter__()
set_sentry_meta(span, "profile", profile)

Expand Down

0 comments on commit c2d0d56

Please sign in to comment.