/** * {@inheritDoc} */ @Override public void setCurrentSpan(final ServerSpan span) { serverSpanState.setCurrentServerSpan(span); }
/** * {@inheritDoc} */ @Override public void setStateNoTracing() { state.setCurrentServerSpan(NOT_SAMPLED); }
/** * Binds given span to current thread. This should typically be called when code is invoked in new thread to bind the * span from the thread in which we received the request to the new execution thread. * * @param span Span to bind to current execution thread. Should not be <code>null</code>. */ public void setCurrentSpan(final ServerSpan span) { state.setCurrentServerSpan(span); }
/** * Binds given span to current thread. This should typically be called when code is invoked in new thread to bind the * span from the thread in which we received the request to the new execution thread. * * @param span Span to bind to current execution thread. Should not be <code>null</code>. */ public void setCurrentSpan(final ServerSpan span) { state.setCurrentServerSpan(span); } }
/** * {@inheritDoc} */ @Override public void clearCurrentSpan() { state.setCurrentServerSpan(null); }
/** * {@inheritDoc} */ @Override public void setStateUnknown(final String spanName) { Validate.notBlank(spanName, "Span name should not be null."); for (final TraceFilter traceFilter : traceFilters) { if (traceFilter.trace(spanName) == false) { state.setCurrentServerSpan(NOT_SAMPLED); return; } } final long newSpanId = randomGenerator.nextLong(); state.setCurrentServerSpan(new ServerSpanImpl(newSpanId, newSpanId, null, spanName)); }
/** * Clears current span. */ public void clearCurrentSpan() { spanAndEndpoint().state().setCurrentServerSpan(null); }
/** * Sets the current Trace/Span state. Using this method indicates that a parent request has decided that we should not * trace the current request. * * @see ServerTracer#setStateCurrentTrace(long, long, Long, String) * @see ServerTracer#setStateUnknown(String) */ public void setStateNoTracing() { spanAndEndpoint().state().setCurrentServerSpan(ServerSpan.NOT_SAMPLED); }
/** * {@inheritDoc} */ @Override public void setStateCurrentTrace(final long traceId, final long spanId, final Long parentSpanId, final String name) { Validate.notEmpty(name, "Span name can't be empty or null."); state.setCurrentServerSpan(new ServerSpanImpl(traceId, spanId, parentSpanId, name)); }
/** * Sets the server sent event for current thread. */ public void setServerSend() { if (submitEndAnnotation(zipkinCoreConstants.SERVER_SEND, spanCollector())) { spanAndEndpoint().state().setCurrentServerSpan(null); } }
/** * Sets the current Trace/Span state. Using this method indicates that we got no information about being part of an * existing trace or about the fact that we should not trace the current request. In this case the ServerTracer will * decide what to do. * * @param spanName The name of our current request/span. */ public void setStateUnknown(String spanName) { checkNotBlank(spanName, "Null or blank span name"); long newTraceId = randomGenerator().nextLong(); if (!traceSampler().isSampled(newTraceId)) { spanAndEndpoint().state().setCurrentServerSpan(ServerSpan.NOT_SAMPLED); return; } spanAndEndpoint().state().setCurrentServerSpan( ServerSpan.create(newTraceId, newTraceId, null, spanName)); }
/** * {@inheritDoc} */ @Override public void setServerSend() { final Span currentSpan = state.getCurrentServerSpan().getSpan(); if (currentSpan != null) { submitAnnotation(zipkinCoreConstants.SERVER_SEND); final long threadDuration = state.getServerSpanThreadDuration(); if (threadDuration > 0) { submitBinaryAnnotation(BraveAnnotations.THREAD_DURATION, String.valueOf(threadDuration)); } collector.collect(currentSpan); state.setCurrentServerSpan(null); } }
/** * Sets the current Trace/Span state. Using this method indicates we are part of an existing trace/span. * * @param traceId Trace id. * @param spanId Span id. * @param parentSpanId Parent span id. Can be <code>null</code>. * @param name Name should not be empty or <code>null</code>. * @see ServerTracer#setStateNoTracing() * @see ServerTracer#setStateUnknown(String) */ public void setStateCurrentTrace(long traceId, long spanId, @Nullable Long parentSpanId, @Nullable String name) { checkNotBlank(name, "Null or blank span name"); spanAndEndpoint().state().setCurrentServerSpan( ServerSpan.create(traceId, spanId, parentSpanId, name)); }