org.eclipse.microprofile.opentracing.Traced Java Examples

The following examples show how to use org.eclipse.microprofile.opentracing.Traced. 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
Source File: TracedEndpoint.java    From Hands-On-Enterprise-Java-Microservices-with-Eclipse-MicroProfile with MIT License 6 votes vote down vote up
@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
Source File: MyService.java    From thorntail with 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 #3
Source File: Endpoint.java    From Hands-On-Enterprise-Java-Microservices-with-Eclipse-MicroProfile with MIT License 5 votes vote down vote up
@GET
@Path("/bonjour")
@Produces(MediaType.TEXT_PLAIN)
@Traced(operationName = "bonjour")
public String bonjour() {
    return "bonjour";
}
 
Example #4
Source File: ServerTracingDynamicFeature.java    From java-jaxrs with 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 #5
Source File: DisabledTestHandler.java    From java-jaxrs with 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 #6
Source File: TestHandler.java    From java-jaxrs with 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 #7
Source File: TestHandler.java    From java-jaxrs with 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 #8
Source File: TestServerWebServices.java    From microprofile-opentracing with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #9
Source File: TestServerWebServices.java    From microprofile-opentracing with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #10
Source File: TracedEndpoint.java    From Hands-On-Enterprise-Java-Microservices-with-Eclipse-MicroProfile with MIT License 5 votes vote down vote up
@GET
@Path("/untraced")
@Produces(MediaType.TEXT_PLAIN)
@Traced(false)
public String untraced() {
    return "No tracing";
}
 
Example #11
Source File: TestServerSkipAllWebServices.java    From microprofile-opentracing with Apache License 2.0 5 votes vote down vote up
@GET
@Traced
@Path(REST_EXPLICITLY_TRACED)
@Produces(MediaType.TEXT_PLAIN)
public Response explicitlyTraced() {
    return Response.ok().build();
}
 
Example #12
Source File: TestServerWebServicesWithOperationName.java    From microprofile-opentracing with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #13
Source File: TestDisabledAnnotatedClass.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced with an operation name.
 */
@Traced(operationName = "explicitOperationName3")
public void annotatedClassMethodExplicitlyTracedWithOperationName() {
    System.out.println("Called annotatedClassMethodExplicitlyTracedWithOperationName");
}
 
Example #14
Source File: ServerTracingDynamicFeature.java    From java-jaxrs with 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;
}
 
Example #15
Source File: ServerTracingDynamicFeature.java    From java-jaxrs with 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 #16
Source File: OpenTracingResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Traced
public String getTest() {
    return "TEST";
}
 
Example #17
Source File: Service.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Traced
public void foo() {
}
 
Example #18
Source File: Service.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Traced
public List<Fruit> getFruits() {
    return em.createNamedQuery("Fruits.findAll", Fruit.class).getResultList();
}
 
Example #19
Source File: ClientServices.java    From microprofile-opentracing with 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 #20
Source File: TestDisabledAnnotatedClass.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced.
 */
@Traced
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example #21
Source File: TestAnnotatedClassWithOperationName.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced explicitly.
 */
@Traced(operationName = "explicitOperationName4")
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example #22
Source File: TestAnnotatedClass.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to not be Traced.
 */
@Traced(operationName = "disabledOperationName", value = false)
public void annotatedClassMethodExplicitlyNotTracedWithOpName() {
    System.out.println("Called annotatedClassMethodExplicitlyNotTracedWithOpName");
}
 
Example #23
Source File: TestAnnotatedClass.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced explicitly.
 */
@Traced(operationName = "explicitOperationName1")
public void annotatedClassMethodExplicitlyTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyTraced");
}
 
Example #24
Source File: TestAnnotatedClass.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to not be Traced.
 */
@Traced(value = false)
public void annotatedClassMethodExplicitlyNotTraced() {
    System.out.println("Called annotatedClassMethodExplicitlyNotTraced");
}
 
Example #25
Source File: TestAnnotatedMethods.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * 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 #26
Source File: TestAnnotatedMethods.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced with operation name.
 */
@Traced(operationName = "explicitOperationName2")
public void annotatedMethodExplicitlyTracedWithOpName() {
    System.out.println("Called annotatedMethodExplicitlyTracedWithOpName");
}
 
Example #27
Source File: TestAnnotatedMethods.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to not be Traced.
 */
@Traced(value = false)
public void annotatedMethodExplicitlyNotTraced() {
    System.out.println("Called annotatedMethodExplicitlyNotTraced");
}
 
Example #28
Source File: TestAnnotatedMethods.java    From microprofile-opentracing with Apache License 2.0 4 votes vote down vote up
/**
 * Method that we expect to be Traced.
 */
@Traced
public void annotatedMethodExplicitlyTraced() {
    System.out.println("Called annotatedMethodExplicitlyTraced");
}