private void addBinaryAnnotation(Span span, BinaryAnnotation ba) { synchronized (span) { span.addToBinary_annotations(ba); } }
private void addBinaryAnnotation(final Span span, final BinaryAnnotation ba) { synchronized (span) { span.addToBinary_annotations(ba); } }
public Span setBinaryAnnotations(List<BinaryAnnotation> binary_annotations) { if (this.binary_annotations != Collections.EMPTY_LIST) this.binary_annotations.clear(); for (BinaryAnnotation b : binary_annotations) addToBinary_annotations(b); return this; }
@Override void address(Span span, String key, Endpoint endpoint) { BinaryAnnotation address = BinaryAnnotation.address(key, endpoint); synchronized (span) { span.addToBinary_annotations(address); } }
@Override public void collect(Span span) { Util.checkNotNull(span, "span must not be null"); for (BinaryAnnotation ba : annotations) { span.addToBinary_annotations(ba); } log.info("{}", span); }
@Override public void collect(Span span) { Util.checkNotNull(span, "span must not be null"); if (log.isTraceEnabled()) { for (BinaryAnnotation ba : annotations) { span.addToBinary_annotations(ba); } log.trace(span.toString()); } }
/** * {@inheritDoc} */ @Override public void collect(final Span span) { metricsHandler.incrementAcceptedSpans(1); final long start = System.currentTimeMillis(); if (!defaultAnnotations.isEmpty()) { for (final BinaryAnnotation ba : defaultAnnotations) { span.addToBinary_annotations(ba); } } final boolean offer = spanQueue.offer(span); if (!offer) { LOGGER.warning("Queue rejected Span, span not submitted: "+ span); metricsHandler.incrementDroppedSpans(1); } else { final long end = System.currentTimeMillis(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Adding span to queue took " + (end - start) + "ms."); } } }
/** * {@inheritDoc} */ @Override public void collect(final Span span) { Validate.notNull(span); if (!defaultAnnotations.isEmpty()) { for (final BinaryAnnotation ba : defaultAnnotations) { span.addToBinary_annotations(ba); } } if (getLogger().isInfoEnabled()) { getLogger().info(span.toString()); } }
@Override void tag(Span span, String key, String value) { BinaryAnnotation ba = BinaryAnnotation.create(key, value, localEndpoint()); synchronized (span) { span.addToBinary_annotations(ba); } }
/** * {@inheritDoc} */ @Override public void collect(final Span span) { checkNotNull(span, "Null span"); if (!defaultAnnotations.isEmpty()) { for (final BinaryAnnotation ba : defaultAnnotations) { span.addToBinary_annotations(ba); } } if (getLogger().isLoggable(Level.INFO)) { getLogger().info(span.toString()); } }
/** * {@inheritDoc} */ @Override public void collect(final Span span) { checkNotNull(span, "Null span"); if (!defaultAnnotations.isEmpty()) { for (final BinaryAnnotation ba : defaultAnnotations) { span.addToBinary_annotations(ba); } } if (getLogger().isLoggable(Level.INFO)) { getLogger().info(span.toString()); } }
/** * Interface method implementation. * @see com.github.kristofa.brave.SpanCollector#collect(com.twitter.zipkin.gen.Span) */ public void collect(Span span) { if (!defaultAnnotations.isEmpty()) { for (final BinaryAnnotation ba : defaultAnnotations) { span.addToBinary_annotations(ba); } } ServiceProxyEvent.Builder eventBuilder = new ServiceProxyEvent.Builder(span.getName(),TRACING_COLLECTOR); eventBuilder.withSpan(span); this.eventProducer.publishEvent(eventBuilder.build()); }
private Span startTrace(HttpServletRequest req, TracePoint point) { String apiName = req.getRequestURI(); Span apiSpan = new Span(); // span basic data long id = Ids.get(); apiSpan.setId(id); apiSpan.setTrace_id(id); apiSpan.setName(point.getKey()); long timestamp = Times.currentMicros(); apiSpan.setTimestamp(timestamp); // sr annotation apiSpan.addToAnnotations( Annotation.create(timestamp, TraceConstants.ANNO_SR, Endpoint.create(apiName, ServerInfo.IP4, req.getLocalPort()))); // app name apiSpan.addToBinary_annotations(BinaryAnnotation.create( "name", conf.getName(), null )); // app owner apiSpan.addToBinary_annotations(BinaryAnnotation.create( "owner", conf.getOwner(), null )); // trace desc if (!Strings.isNullOrEmpty(point.getDesc())){ apiSpan.addToBinary_annotations(BinaryAnnotation.create( "description", point.getDesc(), null )); } return apiSpan; }
private void endTrace(Invoker invoker, Result result, Span consumeSpan, Stopwatch watch) { consumeSpan.setDuration(watch.stop().elapsed(TimeUnit.MICROSECONDS)); // cr annotation URL provider = invoker.getUrl(); consumeSpan.addToAnnotations( Annotation.create(Times.currentMicros(), TraceConstants.ANNO_CR, Endpoint.create(consumeSpan.getName(), Networks.ip2Num(provider.getHost()), provider.getPort()))); // exception catch Throwable throwable = result.getException(); if (throwable != null){ // attach exception consumeSpan.addToBinary_annotations(BinaryAnnotation.create( "Exception", Throwables.getStackTraceAsString(throwable), null )); } // collect the span TraceContext.addSpan(consumeSpan); } }
if (!Strings.isNullOrEmpty(providerOwner)){ consumeSpan.addToBinary_annotations(BinaryAnnotation.create( "owner", providerOwner, null ));
@Override public Span readSpan(byte[] bytes) { zipkin.Span in = codec.readSpan(bytes); Span result = new Span(); result.setTrace_id(in.traceId); result.setId(in.id); result.setParent_id(in.parentId); result.setName(in.name); result.setTimestamp(in.timestamp); result.setDuration(in.duration); result.setDebug(in.debug); for (zipkin.Annotation a : in.annotations) { result.addToAnnotations(Annotation.create( a.timestamp, a.value, to(a.endpoint))); } for (zipkin.BinaryAnnotation a : in.binaryAnnotations) { result.addToBinary_annotations(BinaryAnnotation.create( a.key, a.value, AnnotationType.fromValue(a.type.value), to(a.endpoint))); } return result; }
newSpan.setName(operation); newSpan.setTimestamp(timestamp); newSpan.addToBinary_annotations( BinaryAnnotation.create(LOCAL_COMPONENT, component, spanAndEndpoint().endpoint())); spanAndEndpoint().state().setCurrentLocalSpan(newSpan);
public static Span fromZipkin(zipkin2.Span v2) { V1Span in = V2SpanConverter.create().convert(v2); Span result = newSpan(SpanId.builder() .traceIdHigh(in.traceIdHigh()) .traceId(in.traceId()) .spanId(in.id()) .parentId(in.parentId() != 0L ? in.parentId() : null) .debug(in.debug() != null ? in.debug() : false).build() ); result.setName(in.name()); result.setTimestamp(in.timestamp() != 0L ? in.timestamp() : null); result.setDuration(in.duration() != 0L ? in.duration() : null); for (zipkin2.v1.V1Annotation a : in.annotations()) { result.addToAnnotations(Annotation.create( a.timestamp(), a.value(), to(a.endpoint()))); } for (zipkin2.v1.V1BinaryAnnotation a : in.binaryAnnotations()) { if (a.type() != 0 && a.type() != 6) continue;; result.addToBinary_annotations(BinaryAnnotation.create( a.key(), a.type() == 0 ? new byte[]{1}: a.stringValue().getBytes(UTF_8), a.type() == 0 ? AnnotationType.BOOL : AnnotationType.STRING, to(a.endpoint()))); } return result; }