Exports OTEL initialization function and adds extensive documentation across packages for improved clarity.
This commit is contained in:
@@ -9,10 +9,12 @@ type appConfigKey uint8
|
||||
|
||||
const appConfigCtxKey appConfigKey = iota
|
||||
|
||||
func (a *AppConfig) AddToCtx(ctx context.Context) context.Context {
|
||||
return context.WithValue(ctx, appConfigCtxKey, a)
|
||||
// AddToCtx adds the AppConfig to the provided context.
|
||||
func (ac *AppConfig) AddToCtx(ctx context.Context) context.Context {
|
||||
return context.WithValue(ctx, appConfigCtxKey, ac)
|
||||
}
|
||||
|
||||
// MustFromCtx retrieves the AppConfig from the context, or panics if not found.
|
||||
func MustFromCtx(ctx context.Context) *AppConfig {
|
||||
cfg, err := FromCtx(ctx)
|
||||
if err != nil {
|
||||
@@ -21,6 +23,7 @@ func MustFromCtx(ctx context.Context) *AppConfig {
|
||||
return cfg
|
||||
}
|
||||
|
||||
// FromCtx retrieves the AppConfig from the context.
|
||||
func FromCtx(ctx context.Context) (*AppConfig, error) {
|
||||
ctxData := ctx.Value(appConfigCtxKey)
|
||||
if ctxData == nil {
|
||||
|
Reference in New Issue
Block a user