Search in sources :

Example 1 with TracerException

use of com.couchbase.client.core.error.TracerException in project couchbase-jvm-clients by couchbase.

the class OpenTracingRequestTracer method requestSpan.

@Override
public RequestSpan requestSpan(final String operationName, final RequestSpan parent) {
    try {
        Tracer.SpanBuilder builder = tracer.buildSpan(operationName);
        if (parent != null) {
            builder.asChildOf(castSpan(parent));
        }
        Span span = builder.start();
        tracer.activateSpan(span).close();
        return OpenTracingRequestSpan.wrap(tracer, span);
    } catch (Exception ex) {
        throw new TracerException("Failed to create OpenTracingRequestSpan", ex);
    }
}
Also used : Tracer(io.opentracing.Tracer) RequestTracer(com.couchbase.client.core.cnc.RequestTracer) TracerException(com.couchbase.client.core.error.TracerException) RequestSpan(com.couchbase.client.core.cnc.RequestSpan) Span(io.opentracing.Span) TracerException(com.couchbase.client.core.error.TracerException)

Example 2 with TracerException

use of com.couchbase.client.core.error.TracerException in project couchbase-jvm-clients by couchbase.

the class OpenTelemetryRequestTracer method requestSpan.

@Override
public RequestSpan requestSpan(String operationName, RequestSpan parent) {
    try {
        SpanBuilder spanBuilder = tracer.spanBuilder(operationName);
        Context parentContext = Context.current();
        if (parent != null) {
            parentContext = parentContext.with(castSpan(parent));
        }
        Span span = spanBuilder.setParent(parentContext).startSpan();
        return OpenTelemetryRequestSpan.wrap(span);
    } catch (Exception ex) {
        throw new TracerException("Failed to create OpenTelemetryRequestSpan", ex);
    }
}
Also used : Context(io.opentelemetry.context.Context) SpanBuilder(io.opentelemetry.api.trace.SpanBuilder) TracerException(com.couchbase.client.core.error.TracerException) Span(io.opentelemetry.api.trace.Span) RequestSpan(com.couchbase.client.core.cnc.RequestSpan) TracerException(com.couchbase.client.core.error.TracerException)

Aggregations

RequestSpan (com.couchbase.client.core.cnc.RequestSpan)2 TracerException (com.couchbase.client.core.error.TracerException)2 RequestTracer (com.couchbase.client.core.cnc.RequestTracer)1 Span (io.opentelemetry.api.trace.Span)1 SpanBuilder (io.opentelemetry.api.trace.SpanBuilder)1 Context (io.opentelemetry.context.Context)1 Span (io.opentracing.Span)1 Tracer (io.opentracing.Tracer)1