Skip to content
Permalink
Browse files

Added additional data to span

  • Loading branch information...
evader1337 committed Feb 11, 2019
1 parent 8df8560 commit 1395a1dbf348f667bcd4fd5aa0066ce585274642
@@ -1,7 +1,10 @@
package com.kumuluz.ee.samples.opentracing.tutorial.beta;

import io.opentracing.Tracer;
import org.eclipse.microprofile.opentracing.ClientTracingRegistrar;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -15,15 +18,23 @@
@Path("beta")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class Resource {
private Client client = ClientTracingRegistrar.configure(ClientBuilder.newBuilder()).build();

@Inject
private Tracer tracer;

@GET
public Response get() {
try {
Thread.sleep(ThreadLocalRandom.current().nextInt(1, 1000 + 1));
int waitDelay = ThreadLocalRandom.current().nextInt(1, 1000 + 1);
tracer.activeSpan().setTag("waitDelay", waitDelay);
tracer.activeSpan().log("Waited " + waitDelay + " milliseconds.");
tracer.activeSpan().setBaggageItem("waitDelay", String.valueOf(waitDelay));
Thread.sleep(waitDelay);
Response r1 = client
.target("http://localhost:8081/v1") //alpha
.target("http://localhost:8081/v1")
.path("alpha")
.path("beta")
.request()

0 comments on commit 1395a1d

Please sign in to comment.
You can’t perform that action at this time.