semconv,sdk/log: unwrap single-error errors.Join wrappers in error type derivation #9466
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 274 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.336
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9466"
general
weight: 0.35
pellared
Part of #9446
Summary
In Go,
errors.Joinis commonly used to accumulate optional errors across operations—for example,uploadErr = errors.Join(uploadErr, err)whereuploadErrstarts asnil. When only one non-nil error is passed (e.g.,errors.Join(nil, err)),errors.Joinstill wraps that single error in an unexportederrors.joinErrorimplementingUnwrap() []error(notUnwrap() error).When no error in the chain implements
ErrorType() string,semconv.ErrorTypeandsdk/logfall back to reflection after unwrappingfmt.wrapError(#8133). Becauseerrors.UnwrapreturnsnilforUnwrap() []error, single-errorerrors.Joinwrappers were not unwrapped and caused instrumentation and SDK self-observability metrics to report the opaqueerror.type="errors.joinError"instead of the underlying error's concrete type.Approach
internal/tools/semconvkit/templates/error_type.go.tmpl,semconv/v1.44.0/error_type.go, andsdk/log/logger.goto iteratively unwrap bothfmt.wrapError(fmt.Errorfwith single%w) and single-errorerrors.joinError(errors.Joinwhenlen(u.Unwrap()) == 1).errors.Joinwraps multiple non-nil errors (len > 1continues to reporterrors.joinError) and when custom user-defined error types implementUnwrap() []error(custom wrapper types continue to report their top-level concrete type, matching#8133/#7975).Alternatives Considered
errors.Joinat individual call sites insideopentelemetry-go: Only fixes internal call sites and leaves external instrumentation and callers usingerrors.Join(nil, err)reporting*errors.joinError. Handling single-errorerrors.Joinalongsidefmt.Errorfinsemconvandsdk/logfixes this consistently across the ecosystem.Unwrap() []errorimplementations withlen == 1: Rejected for the same reason#8133/#7975restricted single-error unwrapping tofmt.Errorf: user-defined domain error types implementingUnwrap() []errorcarry meaningful top-level type identity that should not be stripped.