MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / RecordingSpan

Class RecordingSpan

tests/test_tracing.py:30–50  ·  view source on GitHub ↗

A span with a valid context, which records unless a sampler dropped it.

Source from the content-addressed store, hash-verified

28
29
30class RecordingSpan(NonRecordingSpan):
31 """A span with a valid context, which records unless a sampler dropped it."""
32
33 def __init__(self, attributes: Any, *, sampled: bool) -> None:
34 flags = TraceFlags(TraceFlags.SAMPLED if sampled else TraceFlags.DEFAULT)
35 super().__init__(SpanContext(trace_id=1, span_id=1, is_remote=False, trace_flags=flags))
36 self.attributes: dict[str, Any] = dict(attributes or {})
37 self.sampled = sampled
38 self.ended = False
39
40 @override
41 def is_recording(self) -> bool:
42 return self.sampled and not self.ended
43
44 @override
45 def set_attribute(self, key: str, value: Any) -> None:
46 self.attributes[key] = value
47
48 @override
49 def end(self, end_time: int | None = None) -> None:
50 self.ended = True
51
52
53class RecordingTracer(Tracer):

Callers 1

start_spanMethod · 0.85

Calls

no outgoing calls

Tested by 1

start_spanMethod · 0.68