Repository navigation
semconv,sdk/log: unwrap single-error errors.Join wrappers in error type derivation - #9466
Merged
Merged
Conversation
Pull request dashboard statusMerged · refreshed 2026-11-09 20:47 UTC Status above doesn't look right?
|
dashpole
force-pushed
the
unwrap-single-errors-join
branch
from
November 8, 2026 00:51
a285787 to
f352674
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9466 +/- ##
=======================================
- Coverage 89.8% 89.8% -0.1%
=======================================
Files 357 357
Lines 23965 23977 +12
=======================================
+ Hits 21535 21541 +6
- Misses 2430 2436 +6
🚀 New features to boost your workflow:
|
dashpole
marked this pull request as ready for review
November 8, 2026 01:13
dashpole
requested review from
MrAlias,
XSAM,
dmathieu,
pellared and
ps-mir
as code owners
November 8, 2026 01:13
dmathieu
approved these changes
Nov 9, 2026
dashpole
force-pushed
the
unwrap-single-errors-join
branch
from
November 9, 2026 20:16
f352674 to
d543e05
Compare
pellared
approved these changes
Nov 9, 2026
Merged
via the queue into
open-telemetry:main
with commit Nov 9, 2026
1cf898e
49 of 51 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 unexported*errors.joinErrorimplementingUnwrap() []error(notUnwrap() error).When no error in the chain implements
ErrorType() string,semconv.ErrorTypeandsdk/logfall back to reflection after unwrapping*fmt.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 both*fmt.wrapError(fmt.Errorfwith single%w) and single-error*errors.joinError(errors.Joinwhenlen(u.Unwrap()) == 1).errors.Joinwraps multiple non-nil errors (len > 1continues to report*errors.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.