question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenTelemetry not working with RESTEasy reactive mode

See original GitHub issue

Describe the bug

I am trying to setup OpenTelementry on two on Kotlin 1.6.10 and Quarkus 2.6.1. I have a trivial application that takes an input and then makes an HTTP call to another endpoint (on the same application).

If I use RESTEasy Reactive with a synchronous function it works fine. I get a full trace from the HTTP end.

Here is my server:

quarkus.opentelemetry.enabled=true 
quarkus.opentelemetry.propagators=b3,b3multi,tracecontext
quarkus.opentelemetry.tracer.sampler=on
quarkus.opentelemetry.tracer.sampler.parent-based=true
@Path("/hello")
class GreetingController(
    private val tracer: Tracer,

    @RestClient
    private val repeaterClient: RepeaterClient
) {
    @Path("sync")
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    fun sync(name: String): String {
        val span = tracer.spanBuilder("inside sync").startSpan()

        try {
            val repeat = repeaterClient.sync(name)
            return "Hello $name $repeat - sync"
        } finally {
            span.end()
        }
    }

    @Path("async")
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    fun async(name: String): Uni<String> {
        val span = tracer.spanBuilder("inside async").startSpan()

        try {
            return repeaterClient.async(name).onItem()
                .transform { repeat -> "Hello $name $repeat - async" } //.await().indefinitely()
        } finally {
            span.end()
        }
    }

    @Path("coroutine")
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    suspend fun coroutine(name: String): String {
        val span = tracer.spanBuilder("inside coroutine").startSpan()

        try {
            val repeat = repeaterClient.coroutine(name)

            return "Hello $name $repeat - coroutine"
        } finally {
            span.end()
        }
    }
}

@Path("/repeat")
@RegisterRestClient(configKey = "repeater-api")
interface RepeaterClient {
    @Path("repeat")
    @POST
    fun sync(repeat: String): String

    @Path("repeat")
    @POST
    fun async(repeat: String): Uni<String>

    @Path("repeat")
    @POST
    suspend fun coroutine(repeat: String): String
}

@Path("repeat")
class RepeaterController(
    private val tracer: Tracer
) {
    @Path("repeat")
    @POST
    @Produces(MediaType.TEXT_PLAIN)
    fun repeat(repeat: String): String {
        val span = tracer.spanBuilder("inside repeat").startSpan()

        try {
            return repeat
        } finally {
            span.end()
        }
    }
}

If I call /hello/sync I get a single trace that includes the original HTTP POST, inside sync, the HTTP repeat client, the HTTP repeat POST server, and inside repeat.

If I call /hello/async, I get three traces. The first trace is a single space of the HTTP POST (hello/async). The second trace is inside async. And the third trace includes 3 spans the HTTP repeat client, the HTTP repeat POST server, and inside repeat

Using /hello/coroutine gave me the exact same results.

I previously tried Quarkus 2.5.x and it gave slightly different results. Instead of three traces, I got two traces. The first two traces were a single trace.

Expected behavior

I expect a single trace.

Actual behavior

My request is split into three different traces.

How to Reproduce?

No response

Output of uname -a or ver

Darwin MacBook-Pro 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64

Output of java -version

openjdk version “17.0.1” 2021-10-19

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.1-final

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

Gradle 7.3

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
radcortezcommented, Jan 5, 2022

Just to provide some feedback: I was able to reproduce the issue and found a problem in the way the context is retrieved for certain situations. I’ll provide a fix soon.

0reactions
osbornkcommented, Jan 4, 2022

Thanks for looking into this and let me know if you need any further information or testing. I am pushing to introduce Quarkus on GraalVM at my company and this is basically the one last unsolved problem. We love OpenTelemetry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenTelemetry instrumentation stops working for resteasy ...
OTEL instrumentation seems to stop working for resteasy-reactive resources and JDBC calls when dev mode is reloaded (manually or due to a file...
Read more >
Using OpenTelemetry - Quarkus
This guide explains how your Quarkus application can utilize OpenTelemetry to provide distributed tracing for interactive web applications. Prerequisites. To ...
Read more >
Distributed Logs with Quarkus - Google Groups
Problem : Both OpenTracing and OpenTelemetry extensions provided by Quarkus seems not able to manage Reactive model. How can we do to have...
Read more >
Is there a working Quarkus OpenTelemetry support in reactive ...
current() I'm provided with the span created in the REST API abut any attribute or event addition is not propagated to Jaeger; If...
Read more >
Chapter 2. Understand MicroProfile - Red Hat Customer Portal
The method itself is not bound to any fault tolerance interceptor. ... MicroProfile Health is only available when running JBoss EAP as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found