Documentation
¶
Overview ¶
Package phase records one tracing span per phase of a long, sequential operation.
It deliberately lives outside the parent traces package, which pulls in the OTLP exporters: the packages that instrument their phases should not gain a dependency on the exporters to do it. Only the OpenTelemetry API is used here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker records one child span per phase of a long, sequential operation such as a translation, so that its total duration can be attributed to a phase instead of being reported as one opaque span.
The phases run one after another, so a single span is in flight at any time:
phases := phase.NewTracker(ctx, tracer)
defer phases.EndInFlight()
phases.Start("Translator.processRoutes", attribute.Int("routes.count", len(routes)))
processRoutes(routes)
phases.End()
Phase spans stay flat: Start does not hand back the phase's context, so a span started inside a phase parents to the enclosing span, not to the phase.
func NewTracker ¶
NewTracker returns a tracker that starts its phase spans as children of the span in ctx.
func (*Tracker) End ¶
func (p *Tracker) End()
End ends the phase span started by the last call to Start.
func (*Tracker) EndInFlight ¶
func (p *Tracker) EndInFlight()
EndInFlight ends a phase span that was started but never ended, marking it as incomplete. Deferring it keeps the phase visible when the operation panics: a panicking phase is exactly the one an operator needs to see, and an unended span is never exported.