quarkus: Bug/OpenTelemetry extension - unexpected exceptions are not recorded on the span

Describe the bug

My sample application throws an unexpected exception, and I would expect that the current span would contain an event of exception and that attributes of 'exception.messageand/orexception.stacktrace` would be filled. see OTEL Semantic conventions of Exceptions

Expected behavior

whenever there’s an unexpected exception, the OTEL extension should catch it log event of exception and fill span attributes exception.message and/or exception.stacktrace

Actual behavior

the span does not contain event of exception and attributes exception.message and/or exception.stacktrace are not being filled

How to Reproduce?

I used Quick start of Vertx and added to it the following class file

package org.acme;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.StatusCode;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.core.Vertx;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import java.io.IOException;

@Path("/err")
public class ErrResource {

    private final Vertx vertx;

    ErrResource(Vertx vertx) { // <2>
        this.vertx = vertx;
    }

    @GET
    @Path("/genException01")
    public Uni<String> genExc01() {
        throw new RuntimeException("exception 01");
    }

    @GET
    @Path("/genFailure01")
    public Uni<String> genFail01() {
        return Uni.createFrom().failure(new IOException("fail01"));
    }

    @GET
    @Path("/genRecordException")
    public Uni<String> genInternalRecordException() {
        Span currSpan = Span.current();
        currSpan.recordException(new RuntimeException("Got recorded?"));
        currSpan.setStatus(StatusCode.ERROR);
        return Uni.createFrom().item("exception should been recorded");
    }

}
  • Repro 1 - accessing /err/genFailure01

see details at https://github.com/quarkusio/quarkus/issues/30462#issuecomment-1396577651

  • Repro 2 - accessing /err/genException01

see details at https://github.com/quarkusio/quarkus/issues/30462#issuecomment-1396581548

  • Manual recording of exception - accessing /err/genRecordException

see details at https://github.com/quarkusio/quarkus/issues/30462#issuecomment-1396588707

it works as excepted but it means that every user has to do it manually - not ideal. I think that should be the case when unexpected exception is catched within the framework.

Output of uname -a or ver

windows 11

Output of java -version

java 17.0.5 2022-10-18 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 29 (28 by maintainers)

Commits related to this issue

Most upvoted comments

@brunobat , @geoand , @gsmet , @radcortez thanks for solving it 🙏

Here it is.

There is no way to intercept the exception mapper or just chain our own mapper to users, right?

Correct, the spec does not provide for such an integration point

yes then we need a point that we can call just before the mapper is executed.

Cool, I’ll add something to RESTEasy Reactive and then use it in the OpenTelemetry + RR integration

The problem is that all the exception throwing points might not be covered. Some because they are not being catch and some because they might happen before a route can be determined

Right, that’s why I think https://github.com/quarkusio/quarkus/issues/27384 is the proper issue and this one only a subcase of it and should be closed in favor of the former.