/** * {@inheritDoc} */ @Override public void addDefaultAnnotation(final String key, final String value) { defaultAnnotations.add(BinaryAnnotation.create(key, value, null)); }
/** * {@inheritDoc} */ @Override public void addDefaultAnnotation(final String key, final String value) { defaultAnnotations.add(BinaryAnnotation.create(key, value, null)); }
@Override public void addDefaultAnnotation(String key, String value) { annotations.add(BinaryAnnotation.create(key, value, null)); } }
/** * {@inheritDoc} */ @Override public void addDefaultAnnotation(final String key, final String value) { defaultAnnotations.add(BinaryAnnotation.create(key, value, null)); }
@Override public void addDefaultAnnotation(String key, String value) { annotations.add(BinaryAnnotation.create(key, value, null)); } }
/** * Special-cased form supporting client address ("ca") and server address ("sa") * * @param key "ca" or "sa" * @param endpoint associated endpoint. */ public static BinaryAnnotation address(String key, Endpoint endpoint) { return create(key, new byte[] {1}, AnnotationType.BOOL, checkNotNull(endpoint, "endpoint")); }
/** * Special-cased form supporting {@link zipkinCoreConstants#CLIENT_ADDR} and {@link * zipkinCoreConstants#SERVER_ADDR}. * * @param key {@link zipkinCoreConstants#CLIENT_ADDR} or {@link zipkinCoreConstants#SERVER_ADDR} * @param endpoint associated endpoint. */ public static BinaryAnnotation address(String key, Endpoint endpoint) { return create(key, new byte[] {1}, AnnotationType.BOOL, checkNotNull(endpoint, "endpoint")); }
/** String values are the only queryable type of binary annotation. */ public static BinaryAnnotation create(String key, String value, @Nullable Endpoint endpoint) { return create(key, value.getBytes(UTF_8), AnnotationType.STRING, endpoint); }
/** String values are the only queryable type of binary annotation. */ public static BinaryAnnotation create(String key, String value, @Nullable Endpoint endpoint) { return create(key, value.getBytes(UTF_8), AnnotationType.STRING, endpoint); }
@Override void tag(Span span, String key, String value) { BinaryAnnotation ba = BinaryAnnotation.create(key, value, localEndpoint()); synchronized (span) { span.addToBinary_annotations(ba); } }
/** * 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); } }
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.setTimestamp(timestamp); newSpan.addToBinary_annotations( BinaryAnnotation.create(LOCAL_COMPONENT, component, spanAndEndpoint().endpoint())); spanAndEndpoint().state().setCurrentLocalSpan(newSpan); return newSpanId;
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; }