Skip to content

Commit add2067

Browse files
sl0thentr0pyszokeasaurusrex
authored andcommitted
Skeletons for new components
1 parent 25de71e commit add2067

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

0 commit comments

Comments
 (0)