Documentation
¶
Overview ¶
Package reqtrace contains a very simple request tracing framework.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() (enabled bool)
Return false only if traces are disabled, i.e. Trace will never cause a trace to be initiated.
REQUIRES: flag.Parsed()
func StartSpanWithError ¶
A wrapper around StartSpan that can be more convenient to use when the lifetime of a span matches the lifetime of a function. Intended to be used in a defer statement within a function using a named error return parameter.
Equivalent to calling StartSpan with *ctx, replacing *ctx with the resulting new context, then setting f to a function that will invoke the report function with the contents of *error at the time that it is called.
Example:
func DoSomething(ctx context.Context) (err error) { defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() [...] }
Types ¶
type ReportFunc ¶
type ReportFunc func(error)
A function that must be called exactly once to report the outcome of an operation represented by a span.
func StartSpan ¶
Begin a span within the current trace. Return a new context that should be used for operations that logically occur within the span, and a report function that must be called with the outcome of the logical operation represented by the span.
If no trace is active, no span will be created but ctx and report will still be valid.