File tree 2 files changed +58
-0
lines changed
sentry_sdk/integrations/opentelemetry
2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ from opentelemetry .context .context import Context # type: ignore
2
+ from opentelemetry .context .contextvars_context import ContextVarsRuntimeContext # type: ignore
3
+
4
+
5
+ class SentryContextVarsRuntimeContext (ContextVarsRuntimeContext ): # type: ignore
6
+ def attach (self , context ):
7
+ # type: (Context) -> object
8
+ # TODO-neel-potel do scope management
9
+ return super ().attach (context )
10
+
11
+ def detach (self , token ):
12
+ # type: (object) -> None
13
+ # TODO-neel-potel not sure if we need anything here, see later
14
+ super ().detach (token )
Original file line number Diff line number Diff line change
1
+ from opentelemetry .sdk .trace import SpanProcessor # type: ignore
2
+ from opentelemetry .context import Context # type: ignore
3
+ from opentelemetry .trace import Span # type: ignore
4
+
5
+ from sentry_sdk ._types import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING :
8
+ from typing import Optional
9
+
10
+
11
+ class PotelSentrySpanProcessor (SpanProcessor ): # type: ignore
12
+ """
13
+ Converts OTel spans into Sentry spans so they can be sent to the Sentry backend.
14
+ """
15
+
16
+ def __new__ (cls ):
17
+ # type: () -> PotelSentrySpanProcessor
18
+ if not hasattr (cls , "instance" ):
19
+ cls .instance = super ().__new__ (cls )
20
+
21
+ return cls .instance
22
+
23
+ def __init__ (self ):
24
+ # type: () -> None
25
+ pass
26
+
27
+ def on_start (self , span , parent_context = None ):
28
+ # type: (Span, Optional[Context]) -> None
29
+ pass
30
+
31
+ def on_end (self , span ):
32
+ # type: (Span) -> None
33
+ pass
34
+
35
+ # TODO-neel-potel not sure we need a clear like JS
36
+ def shutdown (self ):
37
+ # type: () -> None
38
+ pass
39
+
40
+ # TODO-neel-potel change default? this is 30 sec
41
+ # TODO-neel-potel call this in client.flush
42
+ def force_flush (self , timeout_millis = 30000 ):
43
+ # type: (int) -> bool
44
+ return True
You can’t perform that action at this time.
0 commit comments