context

package
v0.0.0-...-24f16ac Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package context exists to avoid some import cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EOptions

func EOptions(ctx context.Context) []ierr.EOption

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

func SetEOptions(ctx context.Context, options ...ierr.EOption) context.Context

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

func SetShouldTrace(ctx context.Context, b bool) context.Context

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

func ShouldTrace(ctx context.Context) bool

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.

Jump to

Keyboard shortcuts

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