/** * Submits a binary (key/value) annotation with int value. * * @param key Key, should not be blank. * @param value Integer value. */ public void submitBinaryAnnotation(String key, int value) { // Zipkin v1 UI and query only support String annotations. submitBinaryAnnotation(key, String.valueOf(value)); }
/** * Associates an event that explains latency with the current system time. * * @param value A short tag indicating the event, like "finagle.retry" */ public void submitAnnotation(String value) { Span span = spanAndEndpoint().span(); if (span != null) { Annotation annotation = Annotation.create( currentTimeMicroseconds(), value, spanAndEndpoint().endpoint() ); addAnnotation(span, annotation); } }
/** * Binary annotations are tags applied to a Span to give it context. For * example, a key "your_app.version" would let you lookup spans by version. * * @param key Name used to lookup spans, such as "your_app.version" * @param value String value, should not be <code>null</code>. */ public void submitBinaryAnnotation(String key, String value) { Span span = spanAndEndpoint().span(); if (span != null) { BinaryAnnotation ba = BinaryAnnotation.create(key, value, spanAndEndpoint().endpoint()); addBinaryAnnotation(span, ba); } }
/** Internal api for submitting an address. */ void submitAddress(String key, Endpoint endpoint) { Span span = currentSpan().get(); if (span == null) return; recorder().address(span, key, endpoint); }
/** @deprecated Please use {@link Brave#serverTracer()} instead. */ @Deprecated public static AnnotationSubmitter create(final SpanAndEndpoint spanAndEndpoint, final Clock clock) { checkNotNull(spanAndEndpoint, "Null spanAndEndpoint"); checkNotNull(clock, "Null clock"); CurrentSpan currentSpan = new CurrentSpan(){ @Override Span get() { return spanAndEndpoint.span(); } }; Endpoint localEndpoint = spanAndEndpoint.endpoint(); Recorder recorder = new AutoValue_Recorder_Default(localEndpoint, clock, Reporter.NOOP); return create(currentSpan, recorder); }
/** This adds an annotation that corresponds with {@link Span#getTimestamp()} */ void submitStartAnnotation(String annotationName) { Span span = spanAndEndpoint().span(); if (span != null) { Annotation annotation = Annotation.create( currentTimeMicroseconds(), annotationName, spanAndEndpoint().endpoint() ); synchronized (span) { span.setTimestamp(annotation.timestamp); span.addToAnnotations(annotation); } } }
/** * Associates an event that explains latency with a timestamp. * * <p/> This is an alternative to {@link #submitAnnotation(String)}, when * you have a timestamp more precise or accurate than {@link System#currentTimeMillis()}. * * @param value A short tag indicating the event, like "finagle.retry" * @param timestamp microseconds from epoch */ public void submitAnnotation(String value, long timestamp) { Span span = spanAndEndpoint().span(); if (span != null) { Annotation annotation = Annotation.create( timestamp, value, spanAndEndpoint().endpoint() ); addAnnotation(span, annotation); } }
/** This adds an annotation that corresponds with {@link Span#getTimestamp()} */ void submitStartAnnotation(String startAnnotation) { Span span = currentSpan().get(); if (span == null) return; long timestamp = recorder().currentTimeMicroseconds(span); recorder().annotate(span, timestamp, startAnnotation); recorder().start(span, timestamp); }
.build(); serverSpanAnnotationSubmitter = AnnotationSubmitter.create( serverSpanThreadBinder, builder.recorder
/** * This adds an annotation that corresponds with {@link Span#getDuration()}, and sends the span * for collection. * * @return true if a span was sent for collection. */ boolean submitEndAnnotation(String annotationName, SpanCollector spanCollector) { Span span = spanAndEndpoint().span(); if (span == null) { return false; } Annotation annotation = Annotation.create( currentTimeMicroseconds(), annotationName, spanAndEndpoint().endpoint() ); span.addToAnnotations(annotation); if (span.getTimestamp() != null) { span.setDuration(annotation.timestamp - span.getTimestamp()); } spanCollector.collect(span); return true; }
/** @deprecated use {@link #submitBinaryAnnotation(String, String)} */ @Deprecated public final void submitBinaryAnnotation(String key, int value) { // Zipkin v1 UI and query only support String annotations. submitBinaryAnnotation(key, String.valueOf(value)); }
/** * Binary annotations are tags applied to a Span to give it context. For * example, a key "your_app.version" would let you lookup spans by version. * * @param key Name used to lookup spans, such as "your_app.version" * @param value String value, should not be <code>null</code>. */ public void submitBinaryAnnotation(String key, String value) { Span span = currentSpan().get(); if (span == null) return; recorder().tag(span, key, value); }
private Brave(Builder builder) { serverTracer = ServerTracer.builder() .randomGenerator(builder.random) .spanCollector(builder.spanCollector) .state(builder.state) .traceSampler(builder.sampler).build(); clientTracer = ClientTracer.builder() .randomGenerator(builder.random) .spanCollector(builder.spanCollector) .state(builder.state) .traceSampler(builder.sampler).build(); localTracer = LocalTracer.builder() .randomGenerator(builder.random) .spanCollector(builder.spanCollector) .spanAndEndpoint(SpanAndEndpoint.LocalSpanAndEndpoint.create(builder.state)) .traceSampler(builder.sampler).build(); serverRequestInterceptor = new ServerRequestInterceptor(serverTracer); serverResponseInterceptor = new ServerResponseInterceptor(serverTracer); clientRequestInterceptor = new ClientRequestInterceptor(clientTracer); clientResponseInterceptor = new ClientResponseInterceptor(clientTracer); serverSpanAnnotationSubmitter = AnnotationSubmitter.create(SpanAndEndpoint.ServerSpanAndEndpoint.create(builder.state)); serverSpanThreadBinder = new ServerSpanThreadBinder(builder.state); clientSpanThreadBinder = new ClientSpanThreadBinder(builder.state); } }
/** * Internal api for submitting an address. Until a naming function is added, this coerces null * {@code serviceName} to "unknown", as that's zipkin's convention. * * @param ipv4 ipv4 host address as int. Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 * @param port Port for service * @param serviceName Name of service. Should be lowercase and not empty. {@code null} will coerce to "unknown", as that's zipkin's convention. */ void submitAddress(String key, int ipv4, int port, @Nullable String serviceName) { Span span = spanAndEndpoint().span(); if (span != null) { serviceName = serviceName != null ? serviceName : "unknown"; Endpoint endpoint = Endpoint.create(serviceName, ipv4, port); BinaryAnnotation ba = BinaryAnnotation.address(key, endpoint); addBinaryAnnotation(span, ba); } }
public final void accept(AnnotationSubmitter annotationSubmitter, HttpServletRequest input) { if (annotationSubmitter != null) { annotationSubmitter.submitBinaryAnnotation(DubboKeys.HTTP_HEADERS,buildHeader(input).toString()); annotationSubmitter.submitBinaryAnnotation(DubboKeys.HTTP_PARAMS,buildParam(input).toString()); } }
/** * Associates an event that explains latency with the current system time. * * @param value A short tag indicating the event, like "finagle.retry" */ public void submitAnnotation(String value) { Span span = currentSpan().get(); if (span == null) return; recorder().annotate(span, recorder().currentTimeMicroseconds(span), value); }
/** * This adds an annotation that corresponds with {@link Span#getDuration()}, and sends the span * for collection. * * @return true if a span was sent for collection. */ boolean submitEndAnnotation(String finishAnnotation) { Span span = currentSpan().get(); if (span == null) return false; long timestamp = recorder().currentTimeMicroseconds(span); recorder().annotate(span, timestamp, finishAnnotation); recorder().finish(span, timestamp); return true; }
/** * Associates an event that explains latency with a timestamp. * * <p/> This is an alternative to {@link #submitAnnotation(String)}, when * you have a timestamp more precise or accurate than {@link System#currentTimeMillis()}. * * @param value A short tag indicating the event, like "finagle.retry" * @param timestamp microseconds from epoch */ public void submitAnnotation(String value, long timestamp) { Span span = currentSpan().get(); if (span == null) return; recorder().annotate(span, timestamp, value); }