/** * Request a new local span, which starts now. * * @param component in-process component responsible for the operation * @param operation name of the operation that's begun * @return metadata about the new span or null if one wasn't started due to sampling policy. */ public SpanId startNewSpan(String component, String operation) { Span span = newSpan(); if (span == null) return null; return startSpan(component, operation, recorder().currentTimeMicroseconds(span), span); }
/** * 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#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); }
/** * Completes the span, assigning the most precise duration possible. */ public void finishSpan() { Span span = currentSpan().get(); if (span == null) return; recorder().finish(span, recorder().currentTimeMicroseconds(span)); currentSpan().setCurrentSpan(null); }
/** * 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; }