io.opentracing.noop.NoopTracer Java Examples

The following examples show how to use io.opentracing.noop.NoopTracer. 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: AmqpAdapterClientCommandConsumer.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
private static void traceCommand(final HonoConnection con, final ResourceIdentifier address,
        final Message message) {
    final Tracer tracer = con.getTracer();
    if (tracer instanceof NoopTracer) {
        return;
    }

    // try to extract Span context from incoming message
    final SpanContext spanContext = TracingHelper.extractSpanContext(tracer, message);
    final Span currentSpan = createSpan("receive command", address.getTenantId(),
            address.getResourceId(), null, tracer, spanContext);
    final Object correlationId = message.getCorrelationId();
    if (correlationId == null || correlationId instanceof String) {
        final Map<String, String> items = new HashMap<>(5);
        items.put(Fields.EVENT, "received command message");
        TracingHelper.TAG_CORRELATION_ID.set(currentSpan, ((String) correlationId));
        items.put("to", message.getAddress());
        items.put("reply-to", message.getReplyTo());
        items.put("name", message.getSubject());
        items.put("content-type", message.getContentType());
        currentSpan.log(items);
    } else {
        TracingHelper.logError(currentSpan,
                "received invalid command message. correlation-id is not of type string.");
    }
}
 
Example #2
Source File: OpenTracingFilter.java    From Jupiter with Apache License 2.0 6 votes vote down vote up
@Override
public <T extends JFilterContext> void doFilter(JRequest request, T filterCtx, JFilterChain next) throws Throwable {
    Tracer tracer = OpenTracingContext.getTracer();
    if (tracer == null || tracer instanceof NoopTracer) {
        next.doFilter(request, filterCtx);
        return;
    }

    Type filterCtxType = filterCtx.getType();
    if (filterCtxType == Type.PROVIDER) {
        processProviderTracing(tracer, request, filterCtx, next);
    } else if (filterCtxType == Type.CONSUMER) {
        processConsumerTracing(tracer, request, filterCtx, next);
    } else {
        throw new IllegalArgumentException("Illegal filter context type: " + filterCtxType);
    }
}
 
Example #3
Source File: TestUtil.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
private static MockTracer getTracer() {
  final Tracer tracer = getGlobalTracer();
  if (tracer instanceof NoopTracer)
    throw new AssertionError("No tracer is registered");

  return tracer instanceof MockTracer ? (MockTracer)tracer : null;
}
 
Example #4
Source File: TestHandler.java    From java-jaxrs with Apache License 2.0 4 votes vote down vote up
private void assertNoActiveSpan() {
    if (!(tracer instanceof NoopTracer)) {
        Assert.assertNull(tracer.scopeManager().activeSpan());
    }
}
 
Example #5
Source File: TestHandler.java    From java-jaxrs with Apache License 2.0 4 votes vote down vote up
private void assertActiveSpan() {
    if (!(tracer instanceof NoopTracer)) {
        Assert.assertNotNull(tracer.scopeManager().activeSpan());
    }
}
 
Example #6
Source File: DisabledTestHandler.java    From java-jaxrs with Apache License 2.0 4 votes vote down vote up
private void assertNoActiveSpan() {
  if (!(tracer instanceof NoopTracer)) {
    Assert.assertNull(tracer.scopeManager().activeSpan());
  }
}
 
Example #7
Source File: DisabledTestHandler.java    From java-jaxrs with Apache License 2.0 4 votes vote down vote up
private void assertActiveSpan() {
  if (!(tracer instanceof NoopTracer)) {
    Assert.assertNotNull(tracer.scopeManager().activeSpan());
  }
}