Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Thread model breaks tracing #5382

Open
isimsizolan opened this issue Nov 1, 2024 · 5 comments
Open

Virtual Thread model breaks tracing #5382

isimsizolan opened this issue Nov 1, 2024 · 5 comments
Assignees
Labels
Milestone

Comments

@isimsizolan
Copy link

isimsizolan commented Nov 1, 2024

Description

Vert.x has 3 different thread models, worker, vthreads and standart. For high performance web application api we are using ThreadingModel.VIRTUAL _THREAD. However this model breaks tracing (open telemetry, datadog etc), spans are bind together.
If threading model switched to ThreadingModel.WORKER which is the only change, tracing works expectedly and spans bind together correctly.

Version

4.5.10

Context

When using vert.x virtual thread model, tracing breaks (datadog, opentelemetry etc.)

Do you have a reproducer?

non-working
working

Code:

package com.example.starter;

import io.vertx.core.DeploymentOptions;
import io.vertx.core.ThreadingModel;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.rxjava3.core.AbstractVerticle;
import io.vertx.rxjava3.core.http.HttpServer;
import io.vertx.rxjava3.ext.web.Router;

import java.time.LocalDateTime;

public class MainVerticle extends AbstractVerticle {

  @Override
  public void start() throws Exception {
    DeploymentOptions deploymentOptions = new DeploymentOptions().setThreadingModel(ThreadingModel.WORKER);

    vertx.deployVerticle(new HttpServerVerticle(), deploymentOptions).subscribe(s -> {
      vertx.deployVerticle(new MyWebClientVerticle(), deploymentOptions).subscribe(webcleintDeploy -> {
        HttpServer server = vertx.createHttpServer(
          new HttpServerOptions()
        );

        Router router = Router.router(vertx);

        router.get("/").handler(ctx -> {
          // send a message to the event bus
          vertx.eventBus().rxRequest(Constants.EB_REQUEST_1, LocalDateTime.now().toString())
            .subscribe(reply -> {
              ctx.response().end(reply.body().toString());
            });
        });

        router.get("/api").handler(ctx -> {
          // send a message to the event bus
          vertx.eventBus().rxRequest(Constants.EXTERNAL_HTTP_REQUEST, LocalDateTime.now().toString())
            .subscribe(reply -> {
              ctx.response().end(reply.body().toString());
            });
        });

        router.get("/health").handler(ctx -> {
          vertx.eventBus().rxRequest(Constants.HEALTH, ctx.request().method().toString())
            .subscribe(reply -> {
              ctx.response().end(reply.body().toString());
            });
        });

        server.requestHandler(router).listen(8888).subscribe();
        System.out.println("HttpServerVerticle deployed");
      });
    });
  }
}
@isimsizolan isimsizolan added the bug label Nov 1, 2024
@tsegismont
Copy link
Contributor

Can you please update the description? It seems the same piece of code is repeated in image/text formats, but some verticle snippets are missing.

The description must let us understand how to reproduce the problem. Otherwise, we can only guess.

@tsegismont tsegismont added this to the 4.5.11 milestone Nov 4, 2024
@isimsizolan
Copy link
Author

Can you please update the description? It seems the same piece of code is repeated in image/text formats, but some verticle snippets are missing.

The description must let us understand how to reproduce the problem. Otherwise, we can only guess.

Sorry for inconvenience,

Description updated. Using ThreadingModel.VIRTUAL_THREAD causing tracing spans not binding together. Single change to ThreadingModel.WORKER fixes but WORKER model is not what we needed.

@tsegismont
Copy link
Contributor

Thanks for the update, but can you also add snippets of the other verticles that are deployed and instructions about requests to run so that we can try to reproduce? Thank you

@isimsizolan
Copy link
Author

Full code added. @tsegismont
TracingTests.zip

@tsegismont tsegismont self-assigned this Nov 7, 2024
@tsegismont
Copy link
Contributor

Thanks, I'll look into this as soon as I can

@vietj vietj modified the milestones: 4.5.11, 4.5.12 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants