Java Code Examples for org.eclipse.microprofile.opentracing.Traced

The following examples show how to use org.eclipse.microprofile.opentracing.Traced. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@GET
@Path("/randomDelay")
@Produces(MediaType.TEXT_PLAIN)
@Traced(operationName = "TracedEndpoint#demoRandomDelay")
public String randomDelay() {
    long start = System.currentTimeMillis();
    // 0-5 seconds random sleep
    long sleep = Math.round(Math.random() * 5000);
    try {
        Thread.sleep(sleep);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    long end = System.currentTimeMillis();
    return String.format("TracedEndpoint.randomDelay[0-5000], elapsed=%d", (end - start));
}
 
Example 2
@GET
@Path("/bonjour")
@Produces(MediaType.TEXT_PLAIN)
@Traced(operationName = "bonjour")
public String bonjour() {
    return "bonjour";
}
 
Example 3
@GET
@Path("/untraced")
@Produces(MediaType.TEXT_PLAIN)
@Traced(false)
public String untraced() {
    return "No tracing";
}
 
Example 4
@GET
@Traced
@Path(REST_EXPLICITLY_TRACED)
@Produces(MediaType.TEXT_PLAIN)
public Response explicitlyTraced() {
    return Response.ok().build();
}
 
Example 5
/**
 * Test class and endpoint with Traced annotation and operation name.
 *
 * @return OK response
 */
@Traced(operationName = ENDPOINT_OPERATION_NAME)
@GET
@Path(REST_OPERATION_CLASS_AND_METHOD_OP_NAME)
@Produces(MediaType.TEXT_PLAIN)
public Response classAndMethodOperationName() {
    return Response.ok().build();
}
 
Example 6
/**
 * Shouldn't create a span.
 * @return OK response
 */
@Traced(value = false)
@GET
@Path(REST_NOT_TRACED)
@Produces(MediaType.TEXT_PLAIN)
public Response notTraced() {
    return Response.ok().build();
}
 
Example 7
/**
 * Traced with an explicit operation name.
 * @return OK response
 */
@Traced(operationName = REST_OPERATION_NAME)
@GET
@Path(REST_OPERATION_NAME)
@Produces(MediaType.TEXT_PLAIN)
public Response operationName() {
    return Response.ok().build();
}
 
Example 8
Source Project: java-jaxrs   Source File: TestHandler.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/operation")
@Traced(operationName = "renamedOperation")
public Response operation(@Context HttpHeaders headers) {
    assertActiveSpan();
    return Response.status(Response.Status.OK).build();
}
 
Example 9
Source Project: java-jaxrs   Source File: TestHandler.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Path("/tracedFalseIn")
@Traced(operationName = "renamedOperation", value = false)
public Response tracedFalse() {
    assertNoActiveSpan();
    return Response.status(Response.Status.OK).build();
}
 
Example 10
Source Project: java-jaxrs   Source File: DisabledTestHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Traced
@GET
@Path("/enabled")
public Response helloMethod() {
  assertActiveSpan();
  return Response.status(Response.Status.OK).build();
}
 
Example 11
Source Project: java-jaxrs   Source File: ServerTracingDynamicFeature.java    License: Apache License 2.0 5 votes vote down vote up
protected Traced closestTracedAnnotation(ResourceInfo resourceInfo) {
    Traced tracedAnnotation = resourceInfo.getResourceMethod().getAnnotation(Traced.class);
    if (tracedAnnotation == null) {
        tracedAnnotation = resourceInfo.getResourceClass().getAnnotation(Traced.class);
    }

    return tracedAnnotation;
}
 
Example 12
Source Project: thorntail   Source File: MyService.java    License: Apache License 2.0 5 votes vote down vote up
@Traced
public String call() {
    // tag::client-registration[]
    Client client = ClientTracingRegistrar.configure(ClientBuilder.newBuilder()).build();
    // end::client-registration[]
    try {
        String response = client.target("http://localhost:8080")
                .path("/simple")
                .request()
                .get(String.class);
        return "Called an external service successfully, it responded: " + response;
    } finally {
        client.close();
    }
}
 
Example 13
Source Project: quarkus   Source File: OpenTracingResource.java    License: Apache License 2.0 4 votes vote down vote up
@GET
@Traced
public String getTest() {
    return "TEST";
}
 
Example 14
Source Project: quarkus   Source File: Service.java    License: Apache License 2.0 4 votes vote down vote up
@Traced
public void foo() {
}
 
Example 15
Source Project: quarkus   Source File: Service.java    License: Apache License 2.0 4 votes vote down vote up
@Traced
public List<Fruit> getFruits() {
    return em.createNamedQuery("Fruits.findAll", Fruit.class).getResultList();
}
 
Example 16
/**
 * Method that we expect to be Traced.
 */
@Traced
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example 17
/**
 * Method that we expect to be Traced with an operation name.
 */
@Traced(operationName = "explicitOperationName3")
public void annotatedClassMethodExplicitlyTracedWithOperationName() {
    System.out.println("Called annotatedClassMethodExplicitlyTracedWithOperationName");
}
 
Example 18
/**
 * Method that we expect to be Traced.
 */
@Traced
public void annotatedMethodExplicitlyTraced() {
    System.out.println("Called annotatedMethodExplicitlyTraced");
}
 
Example 19
/**
 * Method that we expect to not be Traced.
 */
@Traced(value = false)
public void annotatedMethodExplicitlyNotTraced() {
    System.out.println("Called annotatedMethodExplicitlyNotTraced");
}
 
Example 20
/**
 * Method that we expect to be Traced with operation name.
 */
@Traced(operationName = "explicitOperationName2")
public void annotatedMethodExplicitlyTracedWithOpName() {
    System.out.println("Called annotatedMethodExplicitlyTracedWithOpName");
}
 
Example 21
/**
 * Method that we expect to not be Traced with operation name.
 */
@Traced(value = false, operationName = "disabledOperationName")
public void annotatedMethodExplicitlyNotTracedWithOpName() {
    System.out.println("Called annotatedMethodExplicitlyNotTracedWithOpName");
}
 
Example 22
/**
 * Method that we expect to not be Traced.
 */
@Traced(value = false)
public void annotatedClassMethodExplicitlyNotTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyNotTraced");
}
 
Example 23
/**
 * Method that we expect to be Traced explicitly.
 */
@Traced(operationName = "explicitOperationName1")
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example 24
/**
 * Method that we expect to not be Traced.
 */
@Traced(operationName = "disabledOperationName", value = false)
public void annotatedClassMethodExplicitlyNotTracedWithOpName() {
    System.out.println("Called annotatedClassMethodExplicitlyNotTracedWithOpName");
}
 
Example 25
/**
 * Method that we expect to be Traced explicitly.
 */
@Traced(operationName = "explicitOperationName4")
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example 26
Source Project: microprofile-opentracing   Source File: ClientServices.java    License: Apache License 2.0 4 votes vote down vote up
@GET
@Traced(false)
@Path(TestServerWebServices.REST_SIMPLE_TEST)
@Produces(MediaType.TEXT_PLAIN)
Response disabledTracing();
 
Example 27
Source Project: java-jaxrs   Source File: ServerTracingDynamicFeature.java    License: Apache License 2.0 4 votes vote down vote up
protected boolean tracingDisabled(ResourceInfo resourceInfo) {
    Traced traced = closestTracedAnnotation(resourceInfo);
    return traced == null ? !builder.allTraced : !traced.value();
}
 
Example 28
Source Project: java-jaxrs   Source File: ServerTracingDynamicFeature.java    License: Apache License 2.0 4 votes vote down vote up
protected String operationName(ResourceInfo resourceInfo) {
    Traced traced = closestTracedAnnotation(resourceInfo);
    return traced != null && !traced.operationName().isEmpty()  ? traced.operationName() : null;
}