Fix semconv generated error type to check error chain for custom type declaration#7994
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7994 +/- ##
=======================================
- Coverage 81.6% 81.6% -0.1%
=======================================
Files 304 304
Lines 23385 23389 +4
=======================================
- Hits 19091 19090 -1
- Misses 3905 3911 +6
+ Partials 389 388 -1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the semconv ErrorType helper to detect custom ErrorType() string implementations through wrapped error chains (using errors.As), aligning behavior with common Go error-wrapping patterns.
Changes:
- Update
errorTypeto useerrors.Asso wrapped errors can contributeErrorType() string. - Update doc comments to describe chain-aware
ErrorTypedetection. - Extend generated tests (and templates) to cover wrapped errors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| semconv/v1.40.0/error_type.go | Switches ErrorType detection from direct assertion to chain-aware errors.As; updates docs accordingly. |
| semconv/v1.40.0/error_type_test.go | Adds coverage for wrapped errors and empty ErrorType values in the chain. |
| internal/tools/semconvkit/templates/error_type.go.tmpl | Updates generator template to emit the new chain-aware implementation and docs. |
| internal/tools/semconvkit/templates/error_type_test.go.tmpl | Updates generator template tests to validate wrapped-error behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I think that is a different discussion. I don't see it in the scope of this PR. This is addressing the linked feedback from the previous PR review addressing specifically the detection of the |
Fix
ErrorTypedetection to work through wrapped error chains.errorTypepreviously only checked whether the top-level error value implementedErrorType() string. In common Go usage, errors are often wrapped, so this could missErrorTypeimplementations behind wrappers.