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());
}
}
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);
}
}
Aggregations