Skip to content

fix(instrumentation-http): set conditionally required error.type attribute - #7061

Open
mwear wants to merge 1 commit into
open-telemetry:mainfrom
mwear:http-error-type-7059
Open

fix(instrumentation-http): set conditionally required error.type attribute#7061
mwear wants to merge 1 commit into
open-telemetry:mainfrom
mwear:http-error-type-7059

Conversation

@mwear

@mwear mwear commented Sep 3, 2026

Copy link
Copy Markdown
Member

Which problem is this PR solving?

instrumentation-http sets a span's status to Error from the response status code but never sets error.type on that span. Semconv marks error.type as Conditionally Required "If request has ended with an error", and asks for the status code as a string once a response was received. This PR adds it.

This was an issue identified by the semantic conventions conformance repo.

Fixes #7059

Short description of the changes

  • Add parseErrorType in utils.ts. It returns the status code as a string when the code is an error for that span kind, undefined otherwise.
  • Set the attribute at both points where the span status is derived from a response code, client and server.
  • Route both metric helpers through the same function. This is a refactor with no behavior change: each previously inlined the identical threshold check.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • units, manual testing

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@mwear
mwear requested a review from a team as a code owner September 3, 2026 17:31
@mwear
mwear force-pushed the http-error-type-7059 branch from 18e27cc to f13e573 Compare September 3, 2026 17:32
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 3, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-07 00:37 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (7b155b8) to head (f13e573).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7061   +/-   ##
=======================================
  Coverage   95.00%   95.00%           
=======================================
  Files         407      407           
  Lines       14342    14353   +11     
  Branches     3289     3290    +1     
=======================================
+ Hits        13625    13636   +11     
  Misses        717      717           
Files with missing lines Coverage Δ
...ges/opentelemetry-instrumentation-http/src/http.ts 93.64% <100.00%> (+0.11%) ⬆️
...es/opentelemetry-instrumentation-http/src/utils.ts 88.67% <100.00%> (+0.15%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

instrumentation-http sets span status Error on 4xx/5xx but never sets error.type on the span

1 participant