Skip to content

Always set error type and record error in otelhttp transport #7456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

dmathieu
Copy link
Member

Closes #7254

@dmathieu dmathieu changed the title always set error type and record error in otelhttp transport Always set error type and record error in otelhttp transport Jun 10, 2025
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.3%. Comparing base (088be4b) to head (33d477f).
Report is 41 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7456   +/-   ##
=====================================
  Coverage   82.3%   82.3%           
=====================================
  Files        205     205           
  Lines      17967   17962    -5     
=====================================
- Hits       14794   14792    -2     
+ Misses      2736    2734    -2     
+ Partials     437     436    -1     
Files with missing lines Coverage Δ
instrumentation/net/http/otelhttp/transport.go 96.6% <100.0%> (+1.8%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dmathieu dmathieu marked this pull request as ready for review June 10, 2025 15:01
@dmathieu dmathieu requested a review from a team as a code owner June 10, 2025 15:01
}

span.SetAttributes(t.semconv.ErrorType(err))
span.RecordError(err)
Copy link
Member

@pellared pellared Jun 10, 2025

Choose a reason for hiding this comment

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

What is the value of recording the error as event if the type is set as attribute and value (err.Error()) as status description?

An exception SHOULD be recorded as an Event on the span during which it occurred if and only if it remains unhandled when the span ends and causes the span status to be set to ERROR.

I argue that error result is not an exception. For me a panic that was not being recovered is an unhandled exception. We already cover this part of this specification here:

https://github.com/open-telemetry/opentelemetry-go/blob/bc531cb3f9ce9c328b12e473b6409784728dc608/sdk/trace/span.go#L465-L482

Additionally see: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/recording-errors.md#recording-errors-on-spans

Therefore, we should not call span.RecordError(err).

Suggested change
span.RecordError(err)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want to chime in #7254?

Copy link
Member

Choose a reason for hiding this comment

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

@dashpole dashpole self-requested a review June 12, 2025 16:35
@dmathieu
Copy link
Member Author

Closing per the comment discussion.

@dmathieu dmathieu closed this Jun 24, 2025
@dmathieu dmathieu deleted the otelhttp-errortype branch June 24, 2025 08:39
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.

otelhttp: Cannot record error for spans when producing new semantic convention
3 participants