Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made NoOpSpan compatible to Transactions. #2364

Merged
merged 7 commits into from
Sep 12, 2023
41 changes: 41 additions & 0 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,31 @@ def _set_initial_sampling_decision(self, sampling_context):


class NoOpSpan(Span):
def __init__(
self,
*args, # type: Any
**kwargs # type: Any
):
# type: (...) -> None
pass

def __repr__(self):
# type: () -> str
return self.__class__.__name__

def __enter__(self):
# type: () -> Span
return self

def __exit__(self, ty, value, tb):
# type: (Optional[Any], Optional[Any], Optional[Any]) -> None
pass

@property
def containing_transaction(self):
# type: () -> Optional[Transaction]
return None

def start_child(self, instrumenter=INSTRUMENTER.SENTRY, **kwargs):
# type: (str, **Any) -> NoOpSpan
return NoOpSpan()
Expand All @@ -892,6 +913,10 @@ def to_baggage(self):
# type: () -> Optional[Baggage]
return None

def get_baggage(self):
# type: () -> Optional[Baggage]
return None

def iter_headers(self):
# type: () -> Iterator[Tuple[str, str]]
return iter(())
Expand Down Expand Up @@ -928,6 +953,22 @@ def finish(self, hub=None, end_timestamp=None):
# type: (Optional[sentry_sdk.Hub], Optional[datetime]) -> Optional[str]
pass

def set_measurement(self, name, value, unit=""):
# type: (str, float, MeasurementUnit) -> None
pass

def set_context(self, key, value):
# type: (str, Any) -> None
pass

def init_span_recorder(self, maxlen):
# type: (int) -> None
pass

def _set_initial_sampling_decision(self, sampling_context):
# type: (SamplingContext) -> None
pass


def trace(func=None):
# type: (Any) -> Any
Expand Down