Skip to content

Commit 1e7b694

Browse files
committed
ref: Add no-op streaming span class
1 parent 47e6211 commit 1e7b694

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

sentry_sdk/traces.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,56 @@ def trace_id(self) -> str:
164164
self._trace_id = uuid.uuid4().hex
165165

166166
return self._trace_id
167+
168+
169+
class NoOpStreamedSpan(StreamedSpan):
170+
__slots__ = (
171+
)
172+
173+
def __init__(
174+
self,
175+
) -> None:
176+
pass
177+
178+
def __repr__(self) -> str:
179+
return f"<{self.__class__.__name__}(sampled={self.sampled})>"
180+
181+
def get_attributes(self) -> "Attributes":
182+
return {}
183+
184+
def set_attribute(self, key: str, value: "AttributeValue") -> None:
185+
pass
186+
187+
def set_attributes(self, attributes: "Attributes") -> None:
188+
pass
189+
190+
def remove_attribute(self, key: str) -> None:
191+
pass
192+
193+
@property
194+
def status(self) -> "str":
195+
return SpanStatus.OK.value
196+
197+
@status.setter
198+
def status(self, status: "Union[SpanStatus, str]") -> None:
199+
pass
200+
201+
@property
202+
def name(self) -> str:
203+
return ""
204+
205+
@name.setter
206+
def name(self, value: str) -> None:
207+
pass
208+
209+
@property
210+
def active(self) -> bool:
211+
return True
212+
213+
@property
214+
def span_id(self) -> str:
215+
return "0000000000000000"
216+
217+
@property
218+
def trace_id(self) -> str:
219+
return "00000000000000000000000000000000"

0 commit comments

Comments
 (0)