Skip to content

[otel] Correctly set error code attributes for App API routes#94979

Merged
mischnic merged 7 commits into
canaryfrom
mischnic/otel-api-throw-error
Jun 22, 2026
Merged

[otel] Correctly set error code attributes for App API routes#94979
mischnic merged 7 commits into
canaryfrom
mischnic/otel-api-throw-error

Conversation

@mischnic

@mischnic mischnic commented Jun 19, 2026

Copy link
Copy Markdown
Member

View diff without whitespace

When using adapters, throwing a JS error from a App Route Handler didn't set the OTEL status code correctly.
It was doing this:

try {
	tracer.trace(() => {
		try {
			// handle...
		} finally {
			setOtel();
		}
	});
} catch(e){
	send500();
}

Which I now changed to

	tracer.trace(() => {
		try {
			// handle...
		} catch(e){
			send500();
		} finally {
			setOtel();
		}
	});
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 4658a02

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Stats cancelled

Commit: 4658a02
View workflow run

Comment thread test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts Outdated
@mischnic mischnic force-pushed the mischnic/otel-api-throw-error branch from cb1a4e8 to 865b1f1 Compare June 19, 2026 20:05
@mischnic mischnic force-pushed the mischnic/otel-api-throw-error branch from 865b1f1 to 0f735ba Compare June 22, 2026 07:07
Comment thread test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts Outdated
@mischnic mischnic force-pushed the mischnic/otel-api-throw-error branch from 0f735ba to 921f2a8 Compare June 22, 2026 07:10
@mischnic mischnic force-pushed the mischnic/otel-api-throw-error branch from 921f2a8 to bb1a82e Compare June 22, 2026 07:21
@mischnic mischnic marked this pull request as ready for review June 22, 2026 07:21
@mischnic mischnic changed the title [otel] Correctly set error code attributes for API routes Jun 22, 2026
@mischnic mischnic force-pushed the mischnic/otel-api-throw-error branch 2 times, most recently from d5a1fb1 to 7669527 Compare June 22, 2026 10:57

Copy link
Copy Markdown
Member Author
@mischnic mischnic requested a review from timneutkens June 22, 2026 11:37
@mischnic mischnic merged commit f66c8a6 into canary Jun 22, 2026
129 of 130 checks passed
@mischnic mischnic deleted the mischnic/otel-api-throw-error branch June 22, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants