Skip to content

instrumentation: update error handling to set attributes instead of recording errors#8386

Merged
pellared merged 8 commits intoopen-telemetry:mainfrom
pellared:err-attrs
Jan 13, 2026
Merged

instrumentation: update error handling to set attributes instead of recording errors#8386
pellared merged 8 commits intoopen-telemetry:mainfrom
pellared:err-attrs

Conversation

@pellared
Copy link
Member

@pellared pellared commented Jan 12, 2026

@pellared pellared changed the title feat(instrumentation): update error handling to set attributes instead of recording errors instrumentation: update error handling to set attributes instead of recording errors Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.3%. Comparing base (45a80e1) to head (8af4d8c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8386   +/-   ##
=====================================
  Coverage   82.3%   82.3%           
=====================================
  Files        181     181           
  Lines      13762   13699   -63     
=====================================
- Hits       11327   11278   -49     
+ Misses      2030    2023    -7     
+ Partials     405     398    -7     
Files with missing lines Coverage Δ
...tation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go 97.5% <100.0%> (ø)
.../go-restful/otelrestful/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
...m/gin-gonic/gin/otelgin/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
...com/gorilla/mux/otelmux/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
.../labstack/echo/otelecho/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
...httptrace/otelhttptrace/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
...ation/net/http/otelhttp/internal/semconv/client.go 86.5% <ø> (+0.3%) ⬆️
instrumentation/net/http/otelhttp/transport.go 97.3% <100.0%> (+1.6%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@pellared
Copy link
Member Author

pellared commented Jan 13, 2026

It would be nice to have a linter which not allows calling RecordError. However, we may deprecate this function in future and then this linter would no longer be needed (the existing linter would work). Reference: open-telemetry/opentelemetry-specification#4825

@pellared pellared merged commit 6f2cdf6 into open-telemetry:main Jan 13, 2026
28 checks passed
@pellared pellared deleted the err-attrs branch January 14, 2026 21:39
Eshaan-byte added a commit to Eshaan-byte/opentelemetry-go-contrib that referenced this pull request Jan 22, 2026
… errors

Fixes open-telemetry#8441

This change updates the error handling in otelgin middleware to follow
the instrumentation guidelines established in open-telemetry#8386:

- Replace span.RecordError() calls with span.SetAttributes(ErrorType())
- Set error.type attribute for the first error when c.Errors is not empty
- Multiple errors are still captured in the status description via c.Errors.String()
- Update tests to verify error.type attribute instead of span events

This provides better consistency across OpenTelemetry instrumentation
packages and follows the semantic conventions for error handling.
Eshaan-byte added a commit to Eshaan-byte/opentelemetry-go-contrib that referenced this pull request Jan 22, 2026
… errors

Fixes open-telemetry#8441

This change updates the error handling in otelgin middleware to follow
the instrumentation guidelines established in open-telemetry#8386:

- Replace span.RecordError() calls with span.SetAttributes(ErrorType())
- Set error.type attribute for the first error when c.Errors is not empty
- Multiple errors are still captured in the status description via c.Errors.String()
- Update tests to verify error.type attribute instead of span events

This provides better consistency across OpenTelemetry instrumentation
packages and follows the semantic conventions for error handling.
Eshaan-byte added a commit to Eshaan-byte/opentelemetry-go-contrib that referenced this pull request Jan 28, 2026
… errors

Fixes open-telemetry#8441

This change updates the error handling in otelgin middleware to follow
the instrumentation guidelines established in open-telemetry#8386:

- Replace span.RecordError() calls with span.SetAttributes(ErrorType())
- Set error.type attribute for the first error when c.Errors is not empty
- Multiple errors are still captured in the status description via c.Errors.String()
- Update tests to verify error.type attribute instead of span events

This provides better consistency across OpenTelemetry instrumentation
packages and follows the semantic conventions for error handling.
@MrAlias MrAlias added this to the v1.40.0 milestone Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not use span.RecordError for terminating errors otelhttp: Cannot record error for spans when producing new semantic convention

5 participants