Search in sources :

Example 6 with VertxTracer

use of io.vertx.core.spi.tracing.VertxTracer in project vert.x by eclipse.

the class VertxTestBase method getOptions.

protected VertxOptions getOptions() {
    VertxOptions options = new VertxOptions();
    options.setPreferNativeTransport(USE_NATIVE_TRANSPORT);
    VertxTracer tracer = getTracer();
    if (tracer != null) {
        options.setTracingOptions(new TracingOptions().setFactory(opts -> tracer));
    }
    return options;
}
Also used : Logger(io.vertx.core.impl.logging.Logger) SSLContext(javax.net.ssl.SSLContext) LoggerFactory(io.vertx.core.impl.logging.LoggerFactory) io.vertx.core(io.vertx.core) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) VertxTracer(io.vertx.core.spi.tracing.VertxTracer) CompletableFuture(java.util.concurrent.CompletableFuture) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) io.vertx.core.net(io.vertx.core.net) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) TracingOptions(io.vertx.core.tracing.TracingOptions) List(java.util.List) Rule(org.junit.Rule) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Collections(java.util.Collections) VertxTracer(io.vertx.core.spi.tracing.VertxTracer) TracingOptions(io.vertx.core.tracing.TracingOptions)

Example 7 with VertxTracer

use of io.vertx.core.spi.tracing.VertxTracer in project vert.x by eclipse.

the class OutboundDeliveryContext method next.

@Override
public void next() {
    if (iter.hasNext()) {
        Handler<DeliveryContext> handler = iter.next();
        try {
            if (handler != null) {
                handler.handle(this);
            } else {
                next();
            }
        } catch (Throwable t) {
            EventBusImpl.log.error("Failure in interceptor", t);
        }
    } else {
        VertxTracer tracer = ctx.tracer();
        if (tracer != null) {
            if (message.trace == null) {
                src = true;
                BiConsumer<String, String> biConsumer = (String key, String val) -> message.headers().set(key, val);
                TracingPolicy tracingPolicy = options.getTracingPolicy();
                if (tracingPolicy == null) {
                    tracingPolicy = TracingPolicy.PROPAGATE;
                }
                message.trace = tracer.sendRequest(ctx, SpanKind.RPC, tracingPolicy, message, message.send ? "send" : "publish", biConsumer, MessageTagExtractor.INSTANCE);
            } else {
                // Handle failure here
                tracer.sendResponse(ctx, null, message.trace, null, TagExtractor.empty());
            }
        }
        bus.sendOrPub(this);
    }
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer) TracingPolicy(io.vertx.core.tracing.TracingPolicy) DeliveryContext(io.vertx.core.eventbus.DeliveryContext)

Example 8 with VertxTracer

use of io.vertx.core.spi.tracing.VertxTracer in project vert.x by eclipse.

the class OutboundDeliveryContext method written.

public void written(Throwable failure) {
    // Metrics
    if (metrics != null) {
        boolean remote = (message instanceof ClusteredMessage) && ((ClusteredMessage<?, ?>) message).isToWire();
        metrics.messageSent(message.address(), !message.send, !remote, remote);
    }
    // Tracing
    VertxTracer tracer = ctx.tracer();
    if (tracer != null) {
        Object trace = message.trace;
        if (trace != null) {
            if (src) {
                if (replyHandler != null) {
                    replyHandler.trace = message.trace;
                } else {
                    tracer.receiveResponse(ctx, null, trace, failure, TagExtractor.empty());
                }
            }
        }
    }
    // Fail fast reply handler
    if (failure instanceof ReplyException) {
        if (replyHandler != null) {
            replyHandler.fail((ReplyException) failure);
        }
    }
    // Notify promise finally
    if (writePromise != null) {
        if (failure == null) {
            writePromise.complete();
        } else {
            writePromise.fail(failure);
        }
    }
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer) ClusteredMessage(io.vertx.core.eventbus.impl.clustered.ClusteredMessage) ReplyException(io.vertx.core.eventbus.ReplyException)

Example 9 with VertxTracer

use of io.vertx.core.spi.tracing.VertxTracer in project vert.x by eclipse.

the class Http1xServerConnection method reportResponseComplete.

private void reportResponseComplete() {
    Http1xServerRequest request = responseInProgress;
    if (metrics != null) {
        flushBytesWritten();
        if (requestFailed) {
            metrics.requestReset(request.metric());
            requestFailed = false;
        } else {
            metrics.responseEnd(request.metric(), request.response(), request.response().bytesWritten());
        }
    }
    VertxTracer tracer = context.tracer();
    Object trace = request.trace();
    if (tracer != null && trace != null) {
        tracer.sendResponse(request.context, request.response(), trace, null, HttpUtils.SERVER_RESPONSE_TAG_EXTRACTOR);
    }
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer)

Example 10 with VertxTracer

use of io.vertx.core.spi.tracing.VertxTracer in project vert.x by eclipse.

the class Http2ServerRequest method dispatch.

void dispatch(Handler<HttpServerRequest> handler) {
    VertxTracer tracer = context.tracer();
    if (tracer != null) {
        trace = tracer.receiveRequest(context, SpanKind.RPC, tracingPolicy, this, method().name(), headers(), HttpUtils.SERVER_REQUEST_TAG_EXTRACTOR);
    }
    context.emit(this, handler);
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer)

Aggregations

VertxTracer (io.vertx.core.spi.tracing.VertxTracer)12 io.vertx.core (io.vertx.core)2 Logger (io.vertx.core.impl.logging.Logger)2 LoggerFactory (io.vertx.core.impl.logging.LoggerFactory)2 HttpClientMetrics (io.vertx.core.spi.metrics.HttpClientMetrics)2 WriteStream (io.vertx.core.streams.WriteStream)2 ByteBuf (io.netty.buffer.ByteBuf)1 Unpooled (io.netty.buffer.Unpooled)1 io.netty.channel (io.netty.channel)1 DecoderResult (io.netty.handler.codec.DecoderResult)1 ZlibCodecFactory (io.netty.handler.codec.compression.ZlibCodecFactory)1 io.netty.handler.codec.http (io.netty.handler.codec.http)1 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)1 io.netty.handler.codec.http.websocketx (io.netty.handler.codec.http.websocketx)1 WebSocketFrame (io.netty.handler.codec.http.websocketx.WebSocketFrame)1 V00 (io.netty.handler.codec.http.websocketx.WebSocketVersion.V00)1 V07 (io.netty.handler.codec.http.websocketx.WebSocketVersion.V07)1 V08 (io.netty.handler.codec.http.websocketx.WebSocketVersion.V08)1 V13 (io.netty.handler.codec.http.websocketx.WebSocketVersion.V13)1 WebSocketClientExtensionHandler (io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler)1