@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof SpanAndEndpoint.ClientSpanAndEndpoint) { SpanAndEndpoint.ClientSpanAndEndpoint that = (SpanAndEndpoint.ClientSpanAndEndpoint) o; return (this.state.equals(that.state())); } return false; }
/** * Start a new span for a new client request that will be bound to current thread. The ClientTracer can decide to return * <code>null</code> in case this request should not be traced (eg sampling). * * @param requestName Request name. Should be lowercase and not <code>null</code> or empty. * @return Span id for new request or <code>null</code> in case we should not trace this new client request. */ public SpanId startNewSpan(String requestName) { Boolean sample = spanAndEndpoint().state().sample(); if (Boolean.FALSE.equals(sample)) { spanAndEndpoint().state().setCurrentClientSpan(null); return null; } SpanId newSpanId = getNewSpanId(); if (sample == null) { // No sample indication is present. if (!traceSampler().isSampled(newSpanId.traceId)) { spanAndEndpoint().state().setCurrentClientSpan(null); return null; } } Span newSpan = newSpanId.toSpan(); newSpan.setName(requestName); spanAndEndpoint().state().setCurrentClientSpan(newSpan); return newSpanId; }
public Builder state(ServerClientAndLocalSpanState state) { return spanAndEndpoint(ClientSpanAndEndpoint.create(state)); }
private SpanId getNewSpanId() { Span parentSpan = spanAndEndpoint().state().getCurrentLocalSpan(); if (parentSpan == null) { ServerSpan serverSpan = spanAndEndpoint().state().getCurrentServerSpan(); if (serverSpan != null) { parentSpan = serverSpan.getSpan(); } } long newSpanId = randomGenerator().nextLong(); SpanId.Builder builder = SpanId.builder().spanId(newSpanId); if (parentSpan == null) return builder.build(); // new trace return builder.traceId(parentSpan.getTrace_id()).parentId(parentSpan.getId()).build(); }
/** * {@inheritDoc} */ @Override public Endpoint endpoint() { return state().endpoint(); } }
/** * {@inheritDoc} */ @Override public Span span() { return state().getCurrentClientSpan(); }
/** * {@inheritDoc} */ @Override public Span span() { return state().getCurrentClientSpan(); }
/** * {@inheritDoc} */ @Override public Endpoint endpoint() { return state().endpoint(); } }
/** * Sets the 'client received' event for current thread. This will also submit span because setting a client received * event means this span is finished. */ public void setClientReceived() { if (submitEndAnnotation(zipkinCoreConstants.CLIENT_RECV, spanCollector())) { spanAndEndpoint().state().setCurrentClientSpan(null); } }