Record an exception as an error only when Plug.Exception.status/1 (#165)

returns 500..599.

It is encouraged in the Phoenix docs to use `Plug.Exception` with
custom exceptions to generate for example 404 responses at certain
places. These 404s should not be marked as error, since simple "route
not found" 404s are also not marked as error.

Co-authored-by: Tristan Sloughter <t@crashfast.com>
This commit is contained in:
Derek Kraan 2023-07-06 21:44:16 +02:00 committed by GitHub
parent 4dfda22cef
commit 7119c4bd42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 1 deletions

View File

@ -226,7 +226,6 @@ defmodule OpentelemetryPhoenix do
# record exception and mark the span as errored
Tracer.record_exception(exception, stacktrace, attrs)
Tracer.set_status(OpenTelemetry.status(:error, ""))
# do not close the span as endpoint stop will still be called with
# more info, including the status code, which is nil at this stage