Documentation ¶
Index ¶
- Constants
- func CloneNewContext(ctx context.Context) context.Context
- func ContextWithAttributes(ctx context.Context, attrs ...attribute.KeyValue) context.Context
- func Init() (ctx context.Context, shutdown func(), err error)
- func RecordDebugEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func RecordError(ctx context.Context, err error, attrs ...attribute.KeyValue)
- func RecordInfoEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func RecordWarnEvent(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func Run(ctx context.Context, services ...service)
- func StartSpan(ctx context.Context, name string, async bool, attrs ...attribute.KeyValue) (newCtx context.Context, end func(error))
- type Config
- type Environment
Constants ¶
const ( // EnvProd represents Prod env EnvProd = Environment("production") // EnvStaging represents Staging environment EnvStaging = Environment("staging") // EnvDev represents Development environment EnvDev = Environment("development") )
Variables ¶
This section is empty.
Functions ¶
func CloneNewContext ¶
CloneNewContext returns a new context void of the signals of the given context but inclusive of Config, trace.Span, Zap and Attrs
func ContextWithAttributes ¶
ContextWithAttributes adds the given attributes to the context and the span in the context (if any)
func RecordDebugEvent ¶
RecordDebugEvent records a debug event in both the logs and OTEL span
func RecordError ¶
RecordError records an error in both the logs and OTEL span
func RecordInfoEvent ¶
RecordInfoEvent records an info event in both the logs and OTEL span
func RecordWarnEvent ¶
RecordWarnEvent records a warning event in both the logs and OTEL span
func StartSpan ¶
func StartSpan( ctx context.Context, name string, async bool, attrs ...attribute.KeyValue, ) (newCtx context.Context, end func(error))
StartSpan starts a new span and returns the context with the span and the end func If a span already exists inside the given ctx, the new span is created as a child of the parent span. If async is set to true, then the newCtx is separated from the old ctx's signals. Intentionally didn't use an options pattern for async to force devs to pay attention to when to use sync/async.
Types ¶
type Config ¶
type Config struct { // Env is the environment in which the application is running Env Environment // contains filtered or unexported fields }
Config holds the application config
func ConfigFromContext ¶
ConfigFromContext retrieves the Config from context if exists else return a new Config
type Environment ¶
type Environment string
Environment denotes the environment where the app is running.
func (Environment) IsValid ¶
func (e Environment) IsValid() error
IsValid checks if the environment is valid or not
func (Environment) String ¶
func (e Environment) String() string
String returns the string representation of the environment