MCPcopy
hub / github.com/docker/compose / EventWrapFuncForErrGroup

Function EventWrapFuncForErrGroup

internal/tracing/wrap.go:80–93  ·  internal/tracing/wrap.go::EventWrapFuncForErrGroup

EventWrapFuncForErrGroup invokes a function and records an event, optionally including the returned error as the "exception message" on the event. This is intended for lightweight usage to wrap errgroup.Group calls where a full span is not desired.

(ctx context.Context, eventName string, opts SpanOptions, fn func(ctx context.Context) error)

Source from the content-addressed store, hash-verified

78//
79// This is intended for lightweight usage to wrap errgroup.Group calls where a full span is not desired.
80func EventWrapFuncForErrGroup(ctx context.Context, eventName string, opts SpanOptions, fn func(ctx context.Context) error) func() error {
81 return func() error {
82 span := trace.SpanFromContext(ctx)
83 eventOpts := opts.EventOptions()
84
85 err := fn(ctx)
86 if err != nil {
87 eventOpts = append(eventOpts, trace.WithAttributes(semconv.ExceptionMessage(stripansi.Strip(err.Error()))))
88 }
89 span.AddEvent(eventName, eventOpts...)
90
91 return err
92 }
93}
94
95func AddAttributeToSpan(ctx context.Context, attr ...attribute.KeyValue) {
96 span := trace.SpanFromContext(ctx)

Callers 6

openDockerDesktopMethod · 0.92
openDDComposeUIMethod · 0.92
openDDLogsViewMethod · 0.92
openDDWatchDocsMethod · 0.92
ToggleWatchMethod · 0.92
HandleKeyEventsMethod · 0.92

Calls 2

EventOptionsMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected