Keeps the name and the attributes that each span starts with, which is all that a sampler is given.
| 191 | |
| 192 | |
| 193 | class 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 | |
| 210 | def attributes(span: ReadableSpan) -> dict[str, Any]: |
no outgoing calls