Skip to content

Commit

Permalink
Made NoOpSpan compatible to Transactions. (#2364)
Browse files Browse the repository at this point in the history
Added missing methods from the Transaction to the NoOpSpan because start_transaction sometimes returns a Span (and thus sometimes a NoOpSpan)
  • Loading branch information
antonpirker authored Sep 12, 2023
1 parent d26b91c commit 113b461
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,11 @@ def __repr__(self):
# type: () -> str
return self.__class__.__name__

@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 +897,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 +937,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

0 comments on commit 113b461

Please sign in to comment.