[Java] agent transaction tracing in non-web Vert.x applications

Hi.

I’m interested in your thoughts on how best to instrument tracing of non-web transactions in a Vert.x application.

I’ve looked at the docs and javadocs for the Agent API and asynchronous tracing however the current implementation requires the passing of Token or Segment objects to functions that (potentially) get executed on separate threads.

What happens if I would like to trace code that crosses the Vert.x event bus? There doesn’t appear to be a way to easily retrieve the transaction/token/segment that originated a process that gets called as a result of a message on the event bus.

Here’s an example:

	@Trace(dispatcher = true)	
private void processSomeEvent(AsyncResult<Response> event, Promise<Object> future) {

	if (event.succeeded()) {
		Response response = event.result();
		if (response != null) {
			String content = deserializeEvent(response);

			LOG.debug("Got event {}", content);
			NewRelic.setTransactionName(null, "/processing-stuff");

			// Forward the event to some handler
			DeliveryOptions options = new DeliveryOptions()
					.addHeader("my-key", "my-value");
			JsonObject data = new JsonObject(content);
			vertx.eventBus().send("my-queue", data, options);
		}
		future.complete(true);
	}
	else {
		future.fail(event.cause());
	}
}

My code will then have a method registered with the event bus to handle messages received on the “my-queue” topic.

If I want to link the processing in that handler method with the transaction created above, how would I go about that?

From what I can tell, there is nothing exposed that uniquely identifies a Transaction, Token, or Segment so I can’t just pass an “id” across the wire and have the handler code look it up when invoked on the other side.

Another option would be to serialize the Token/Segment and send it on the event bus however that would require knowledge of the implementation of those interfaces.

It looks like the only option is to manually keep track of the Token and/or Segment by generating an id, storing the Token/Segment in my own list based on said id, and then passing that id over the event bus for looking up “on the other side”.

Is this assessment accurate?

Curious if I’m missing something or if you have other ideas on how best to accomplish this type of tracing.

Thanks!

  • APM Agent Language
    Java

  • APM Agent Version
    5.14.0

  • Operating System
    Linux

  • Operating System Version
    Any

  • Frameworks your app is using
    Vert.x

1 Like

Hi @greg10, Sorry you have been waiting awhile for a response from our community.
I’m going to bring this back to the attention of our support team. Thanks for your patience!

Neal Mc

1 Like

I am suspecting that NewRelic tracing does not work as soon as work is handed over to the vert.x bus. I am trying it out for a vert.x web application, and I don’t see any tracing after the first bus call.

This project enforces my suspicion: https://github.com/newrelic-experimental/newrelic-java-vertx

1 Like

Hi @Max_Wenzin

Sorry for the delay in answering you.

I’m wondering if you are still working on these transaction traces on this Vert.x app?

thanks

Rodrigo

Hi @rcorgozinho,

I posted the original question. I’ve basically had to settle on breaking up my transactions into discrete parts rather than tracking as one cohesive unit. It’s not the end-of-the-world however if you’re able to point me in a direction that allows me to track the transactions across the Vert.x event bus then that would be great.

If that isn’t possible at this time then consider this a feature request to provide in the future!

Thanks,
Greg

@greg10 Thank you for providing an update. :slight_smile: I’ll followup with our product team to see if this is a feature in process or not. If not, I will get this submitted.

Hi, @greg10: You might take a look at this project in the newrelic-experimental Github repo: GitHub - newrelic-experimental/newrelic-java-vertx: Provides instrumentation for Vertx EventBus and Verticles.