apptracing

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

func Start(ctx context.Context, def appstep.Def, kv ...any) (context.Context, *Span)

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

func (s *Span) End(errp *error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL