Documentation
¶
Overview ¶
Package context exists to avoid some import cycles.
Index ¶
- func EOptions(ctx context.Context) []ierr.EOption
- func MeterProvider(ctx context.Context) metric.MeterProvider
- func SetEOptions(ctx context.Context, options ...ierr.EOption) context.Context
- func SetShouldTrace(ctx context.Context, b bool) context.Context
- func ShouldTrace(ctx context.Context) bool
- type EOptionKey
- type MetricsKey
- type ShouldTraceKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EOptions ¶
EOptions returns the error options attached to the context. If no options are attached, it returns nil. This allows for setting per call error options. These will override local options if the same options are set. An example of this is writing a traceback to errors on a specific call or all calls.
func MeterProvider ¶
func MeterProvider(ctx context.Context) metric.MeterProvider
MeterProvider returns a metric.MeterProvider attached to the context. If no meter provider is attached, it returns metrics.Default(). This may be a noop provider.
func SetEOptions ¶
SetEOptions attaches error options to the context. This allows for setting per call error options. These will override local options if the same options are set. An example of this is writing a traceback to errors on a specific call or all calls.
func SetShouldTrace ¶
SetShouldTrace attaches a boolean value to the context to indicate if the request should be traced. This is not usually used by a service, but by the middleware to determine if the request should be traced. This only works if done before the trace is started.
func ShouldTrace ¶
ShouldTrace returns true if the request has had SetShouldTrace called on it.
Types ¶
type EOptionKey ¶
type EOptionKey struct{}
EOptionKey is a key for the context that stores an errors.EOption.
type MetricsKey ¶
type MetricsKey struct{}
MetricsKey is a key for the context that stores a metrics.MeterProvider.
type ShouldTraceKey ¶
type ShouldTraceKey struct{}
ShouldTraceKey is a key for the context that stores a bool.