MCPcopy
hub / github.com/docker/docker-agent / RecordError

Method RecordError

pkg/telemetry/mcp/span.go:175–188  ·  view source on GitHub ↗

RecordError marks the span as failed and stores error.type for the duration metric. errType should be a short, low-cardinality string; when empty, ClassifyError(err) supplies a value (one of "context_canceled", "deadline_exceeded", "rpc_error").

(err error, errType string)

Source from the content-addressed store, hash-verified

173// when empty, ClassifyError(err) supplies a value (one of
174// "context_canceled", "deadline_exceeded", "rpc_error").
175func (s *Span) RecordError(err error, errType string) {
176 if s == nil || err == nil {
177 return
178 }
179 if errType == "" {
180 errType = ClassifyError(err)
181 }
182 s.mu.Lock()
183 s.errType = errType
184 s.mu.Unlock()
185 s.span.RecordError(err)
186 s.span.SetStatus(codes.Error, err.Error())
187 s.span.SetAttributes(attribute.String("error.type", errType))
188}
189
190// End closes the span and records the operation duration metric. Safe to
191// call multiple times; subsequent calls are no-ops.

Callers

nothing calls this directly

Calls 7

ClassifyErrorFunction · 0.70
RecordErrorMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
ErrorMethod · 0.45
SetAttributesMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected