Search in sources :

Example 11 with VertxTracer

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

the class Http1xClientConnection method handleClosed.

protected void handleClosed() {
    super.handleClosed();
    long timerID = shutdownTimerID;
    if (timerID != -1) {
        shutdownTimerID = -1L;
        vertx.cancelTimer(timerID);
    }
    closed = true;
    if (metrics != null) {
        HttpClientMetrics met = client.metrics();
        met.endpointDisconnected(metrics);
    }
    if (!evicted) {
        evicted = true;
        if (evictionHandler != null) {
            evictionHandler.handle(null);
        }
    }
    WebSocketImpl ws;
    VertxTracer tracer = context.tracer();
    List<Stream> allocatedStreams;
    List<Stream> sentStreams;
    synchronized (this) {
        ws = webSocket;
        sentStreams = new ArrayList<>(responses);
        allocatedStreams = new ArrayList<>(requests);
        allocatedStreams.removeAll(responses);
    }
    if (ws != null) {
        ws.handleConnectionClosed();
    }
    for (Stream stream : allocatedStreams) {
        stream.context.execute(null, v -> stream.handleClosed());
    }
    for (Stream stream : sentStreams) {
        if (metrics != null) {
            metrics.requestReset(stream.metric);
        }
        Object trace = stream.trace;
        if (tracer != null && trace != null) {
            tracer.receiveResponse(stream.context, null, trace, ConnectionBase.CLOSED_EXCEPTION, TagExtractor.empty());
        }
        stream.context.execute(null, v -> stream.handleClosed());
    }
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer) HttpClientMetrics(io.vertx.core.spi.metrics.HttpClientMetrics) WriteStream(io.vertx.core.streams.WriteStream)

Example 12 with VertxTracer

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

the class Http1xClientConnection method beginRequest.

private void beginRequest(Stream stream, HttpRequestHead request, boolean chunked, ByteBuf buf, boolean end, boolean connect, Handler<AsyncResult<Void>> handler) {
    request.id = stream.id;
    request.remoteAddress = remoteAddress();
    stream.bytesWritten += buf != null ? buf.readableBytes() : 0L;
    HttpRequest nettyRequest = createRequest(request.method, request.uri, request.headers, request.authority, chunked, buf, end);
    synchronized (this) {
        responses.add(stream);
        this.isConnect = connect;
        if (this.metrics != null) {
            stream.metric = this.metrics.requestBegin(request.uri, request);
        }
        VertxTracer tracer = context.tracer();
        if (tracer != null) {
            BiConsumer<String, String> headers = (key, val) -> nettyRequest.headers().add(key, val);
            String operation = request.traceOperation;
            if (operation == null) {
                operation = request.method.name();
            }
            stream.trace = tracer.sendRequest(stream.context, SpanKind.RPC, options.getTracingPolicy(), request, operation, headers, HttpUtils.CLIENT_HTTP_REQUEST_TAG_EXTRACTOR);
        }
    }
    writeToChannel(nettyRequest, handler == null ? null : context.promise(handler));
    if (end) {
        endRequest(stream);
    }
}
Also used : NetSocketImpl(io.vertx.core.net.impl.NetSocketImpl) java.util(java.util) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) InboundBuffer(io.vertx.core.streams.impl.InboundBuffer) LoggerFactory(io.vertx.core.impl.logging.LoggerFactory) io.vertx.core(io.vertx.core) ContextInternal(io.vertx.core.impl.ContextInternal) HttpClientMetrics(io.vertx.core.spi.metrics.HttpClientMetrics) ConnectionBase(io.vertx.core.net.impl.ConnectionBase) Unpooled(io.netty.buffer.Unpooled) WebSocketClientExtensionHandshaker(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandshaker) ByteBuf(io.netty.buffer.ByteBuf) HttpVersion(io.vertx.core.http.HttpVersion) SpanKind(io.vertx.core.spi.tracing.SpanKind) WriteStream(io.vertx.core.streams.WriteStream) BiConsumer(java.util.function.BiConsumer) io.netty.channel(io.netty.channel) URI(java.net.URI) ZlibCodecFactory(io.netty.handler.codec.compression.ZlibCodecFactory) V13(io.netty.handler.codec.http.websocketx.WebSocketVersion.V13) SocketAddress(io.vertx.core.net.SocketAddress) Logger(io.vertx.core.impl.logging.Logger) VertxHandler(io.vertx.core.net.impl.VertxHandler) IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) PromiseInternal(io.vertx.core.impl.future.PromiseInternal) WebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame) FutureListener(io.netty.util.concurrent.FutureListener) PerMessageDeflateServerExtensionHandshaker(io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateServerExtensionHandshaker) TagExtractor(io.vertx.core.spi.tracing.TagExtractor) VertxTracer(io.vertx.core.spi.tracing.VertxTracer) HttpHeaders(io.vertx.core.http.HttpHeaders) io.vertx.core.http(io.vertx.core.http) HeadersAdaptor(io.vertx.core.http.impl.headers.HeadersAdaptor) DecoderResult(io.netty.handler.codec.DecoderResult) io.netty.handler.codec.http(io.netty.handler.codec.http) WebSocketClientExtensionHandler(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler) Buffer(io.vertx.core.buffer.Buffer) V08(io.netty.handler.codec.http.websocketx.WebSocketVersion.V08) io.netty.handler.codec.http.websocketx(io.netty.handler.codec.http.websocketx) PerMessageDeflateClientExtensionHandshaker(io.netty.handler.codec.http.websocketx.extensions.compression.PerMessageDeflateClientExtensionHandshaker) HttpMethod(io.vertx.core.http.HttpMethod) DeflateFrameClientExtensionHandshaker(io.netty.handler.codec.http.websocketx.extensions.compression.DeflateFrameClientExtensionHandshaker) ReferenceCountUtil(io.netty.util.ReferenceCountUtil) ClientMetrics(io.vertx.core.spi.metrics.ClientMetrics) V07(io.netty.handler.codec.http.websocketx.WebSocketVersion.V07) V00(io.netty.handler.codec.http.websocketx.WebSocketVersion.V00) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) 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