Documentation
¶
Overview ¶
Package apptracing runs the steps appstep defines.
Start begins a step: a span in the trace, named for the step, its parameters as attributes with the sensitive ones redacted. End finishes it, and if the function is failing, adds the step to its error through apperr.WithStep, leaving the error's meaning as it was.
A span is marked as errored only for a server-scope failure: a user's invalid input or a client's missing session is the system working, and an error status on it would bury the failures that need someone. Every failing span carries error.type, the code, so the others are still findable.
OpenTelemetry stays in this package: neither appstep nor apperr knows of tracing. Spans go to the global tracer provider, which the host installs; without it they are no-ops, and the error half works the same.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span is one running step.
func Start ¶
Start starts a step of def. Its End must be deferred with a pointer to the enclosing function's named error result:
func (s *Imports) importOne(ctx context.Context, f File) (err error) {
ctx, span := apptracing.Start(ctx, steps.ImportDashboard, "name", f.Name)
defer span.End(&err)
...
}
kv are key/value pairs, as in slog. Which are sensitive is def's declaration.
func (*Span) End ¶
End ends the step. If the function is failing, the step is added to its error, leaving the error's meaning as it was. A second call does nothing.
Deferred, it also sees a panic passing through: the span records it and is marked as errored, and the panic goes on unchanged to whatever recovers it.