MCPcopy
hub / github.com/microsoft/agent-lightning / Span

Class Span

agentlightning/types/tracer.py:251–478  ·  view source on GitHub ↗

Agent Lightning's canonical span model used for persistence and analytics. The model captures the most relevant fields from `opentelemetry.sdk.trace.ReadableSpan` instances while preserving unmodeled attributes in Pydantic `BaseModel`'s extra storage. This keeps the serialized format

Source from the content-addressed store, hash-verified

249
250
251class Span(BaseModel):
252 """Agent Lightning's canonical span model used for persistence and analytics.
253
254 The model captures the most relevant fields from
255 `opentelemetry.sdk.trace.ReadableSpan` instances while preserving unmodeled
256 attributes in Pydantic `BaseModel`'s extra storage. This keeps the serialized format
257 stable even as upstream OpenTelemetry types evolve.
258 """
259
260 model_config = ConfigDict(extra="allow")
261
262 rollout_id: str
263 """The rollout which this span belongs to."""
264 attempt_id: str
265 """The attempt which this span belongs to."""
266 sequence_id: int
267 """The ID to make spans ordered within a single attempt."""
268
269 # Current ID (in hex, formatted via trace_api.format_*)
270 trace_id: str # one rollout can have traces coming from multiple places
271 """The trace ID of the span. One rollout/attempt can have multiple traces.
272 This ID comes from the OpenTelemetry trace ID generator.
273 """
274 span_id: str
275 """The span ID of the span. This ID comes from the OpenTelemetry span ID generator."""
276 parent_id: Optional[str]
277 """The parent span ID of the span."""
278
279 # Core ReadableSpan fields
280 name: str
281 """The name of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
282 status: TraceStatus
283 """The status of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
284 attributes: Attributes
285 """The attributes of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
286 events: List[Event]
287 """The events of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
288 links: List[Link]
289 """The links of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
290
291 # Timestamps
292 start_time: Optional[float]
293 """The start time of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
294 end_time: Optional[float]
295 """The end time of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
296
297 # Other parsable fields
298 context: Optional[SpanContext]
299 """The context of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
300 parent: Optional[SpanContext]
301 """The parent context of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
302 resource: OtelResource
303 """The resource of the span. See [OpenTelemetry docs](https://opentelemetry.io/docs/concepts/signals/traces/)."""
304
305 # Preserve other fields in the readable span as extra fields
306 # Make sure that are json serializable (so no bytes, complex objects, ...)
307
308 @classmethod

Callers 15

spans_from_protoFunction · 0.90
convert_call_to_spanMethod · 0.90
_make_spanFunction · 0.90
_make_spanFunction · 0.90
_make_spanFunction · 0.90
_build_spanFunction · 0.90
build_spanFunction · 0.90
make_spanFunction · 0.90
make_spanFunction · 0.90
make_reward_spanFunction · 0.90

Calls

no outgoing calls

Tested by 11

_make_spanFunction · 0.72
_make_spanFunction · 0.72
_build_spanFunction · 0.72
build_spanFunction · 0.72
make_spanFunction · 0.72
make_spanFunction · 0.72
make_reward_spanFunction · 0.72
_build_spanFunction · 0.72
make_spanFunction · 0.72