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

Class StartAttributes

tests/test_open_telemetry.py:193–207  ·  view source on GitHub ↗

Keeps the name and the attributes that each span starts with, which is all that a sampler is given.

Source from the content-addressed store, hash-verified

191
192
193class StartAttributes(sampling.Sampler):
194 """Keeps the name and the attributes that each span starts with, which is all that a sampler is given."""
195
196 def __init__(self) -> None:
197 self.started: list[tuple[str, dict[str, Any]]] = []
198
199 @override
200 def should_sample(self, *args: Any, **kwargs: Any) -> sampling.SamplingResult:
201 name, attributes = kwargs.get("name", args[2] if len(args) > 2 else None), kwargs.get("attributes")
202 self.started.append((str(name), dict(attributes or (args[4] if len(args) > 4 else None) or {})))
203 return sampling.ALWAYS_ON.should_sample(*args, **kwargs)
204
205 @override
206 def get_description(self) -> str:
207 return "start attributes"
208
209
210def attributes(span: ReadableSpan) -> dict[str, Any]:

Calls

no outgoing calls