Span Groups
Span granularity in Megatron is controlled by the MEGATRON_OTEL_SPAN_GROUPS env var (or --otel-span-groups CLI flag). The spec accepts preset keywords, individual group names, or a mix.
For the general span-group mechanism see lens: span groups. This page covers Megatron’s extensions and the complete span hierarchy.
Preset keywords
MegatronSpanGroup
Defined in megatron/core/telemetry/span_groups.py. Extends lens’s base SpanGroup with Megatron-specific groups:
Examples
Span hierarchy
The full tree of spans Megatron can emit, with the controlling span group shown per span:
Span attributes
Key Megatron-specific span attributes:
Granularity guidance
Non-exporting ranks have frozenset() span groups — is_span_group_enabled() returns False everywhere, so no span objects are created at all. The disabled path is a frozenset lookup followed by an immediate return, not a no-op span that still allocates. See lens: architecture.