Skip to content

Quarkus redirects lost traces #37211

Open
@ukrcoder

Description

Describe the bug

Using quarkus 3.4.3 and latest opentelemetry there. I want whole my flow be linked and to see it inside zipkin/jaeger (no matter). But when I have redirects in my code -> than I'll always have separate track and new traceId flow.

I cannot always pass traceparent header because of ui (in that case secured cookies could be used so I can store state). But adding as a header doesn't help to link to the parent.

Tried to add parent to the context with next code
`String[] values = traceparentCookie.split("-");

    SpanContext parentContext = SpanContext.create(values[1], values[2], TraceFlags.getSampled(), TraceState.getDefault());
    Span parentSpan = Span.wrap(parentContext);
    Log.infof("TRACEPARENT DATA: trace is = " + values[1] + " and span is = " + values[2]);

    Span span = tracer.spanBuilder("ui-provider-picker").setParent(Context.current().with(parentSpan)).startSpan();
    try (Scope scope = span.makeCurrent()) {
    } finally {
        span.setAttribute("test", "12345");
        span.end();
    }`

it creates new span and attaches to base process as a last one and then starts new trace with needed me endpoint. It's also created as an empty one without tags or any info.

Overall what I want: to link one span with another one retrieving all needed tags. Couldn't find solution meanwhile.
Any suggestions?

Expected behavior

Expected linked flow of multiple actions on redirect.

Actual behavior

Additional span inside main flow and new trace and span for redirected action

How to Reproduce?

 @GET
    public Uni<RestResponse<Void>> test() {
        try {
            URI uri = new URI("http://localhost:8080/ui");
            RestResponse.ResponseBuilder<Void> objectResponseBuilder = RestResponse.ResponseBuilder.seeOther(uri);
            return Uni.createFrom().item(objectResponseBuilder.build());
        } catch (URISyntaxException e) {
            throw new URLParserException(e);
        }
    }

"http://localhost:8080/ui" - will be added as a new trace in zipkin.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions