Skip to content

Commit 5db5874

Browse files
authored
ref: Add no-op streaming span class (#5591)
### Description We'll use `NoOpStreamedSpan`s for spans that have a negative sampling decision or were filtered out via `ignore_spans`. They will get some minimal `__slots__` and `__init__` in a future PR. #### Issues <!-- * resolves: #1234 * resolves: LIN-1234 --> #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent e9d6782 commit 5db5874

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

sentry_sdk/traces.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,45 @@ 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+
def get_attributes(self) -> "Attributes":
171+
return {}
172+
173+
def set_attribute(self, key: str, value: "AttributeValue") -> None:
174+
pass
175+
176+
def set_attributes(self, attributes: "Attributes") -> None:
177+
pass
178+
179+
def remove_attribute(self, key: str) -> None:
180+
pass
181+
182+
@property
183+
def status(self) -> "str":
184+
return SpanStatus.OK.value
185+
186+
@status.setter
187+
def status(self, status: "Union[SpanStatus, str]") -> None:
188+
pass
189+
190+
@property
191+
def name(self) -> str:
192+
return ""
193+
194+
@name.setter
195+
def name(self, value: str) -> None:
196+
pass
197+
198+
@property
199+
def active(self) -> bool:
200+
return True
201+
202+
@property
203+
def span_id(self) -> str:
204+
return "0000000000000000"
205+
206+
@property
207+
def trace_id(self) -> str:
208+
return "00000000000000000000000000000000"

0 commit comments

Comments
 (0)