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