/** * Idempotently sets correlation properties to hex representation of trace identifiers in this * context. */ void maybeReplaceTraceContext( TraceContext currentSpan, String previousTraceId, @Nullable String previousParentId, String previousSpanId ) { String traceId = currentSpan.traceIdString(); if (!traceId.equals(previousTraceId)) put("traceId", currentSpan.traceIdString()); String parentId = currentSpan.parentIdString(); if (parentId == null) { remove("parentId"); } else { boolean sameParentId = parentId.equals(previousParentId); if (!sameParentId) put("parentId", parentId); } String spanId = currentSpan.spanIdString(); if (!spanId.equals(previousSpanId)) put("spanId", spanId); }
@Override public boolean handle(TraceContext context, MutableSpan span) { if (!Boolean.TRUE.equals(context.sampled())) return true; Span.Builder builderWithContextData = Span.newBuilder() .traceId(context.traceIdString()) .parentId(context.parentIdString()) .id(context.spanIdString()); if (context.debug()) builderWithContextData.debug(true); converter.convert(span, builderWithContextData); spanReporter.report(builderWithContextData.build()); return true; }
@Override public void inject(TraceContext traceContext, C carrier) { setter.put(carrier, propagation.traceIdKey, traceContext.traceIdString()); setter.put(carrier, propagation.spanIdKey, traceContext.spanIdString()); String parentId = traceContext.parentIdString(); if (parentId != null) { setter.put(carrier, propagation.parentSpanIdKey, parentId); } if (traceContext.debug()) { setter.put(carrier, propagation.debugKey, "1"); } else if (traceContext.sampled() != null) { setter.put(carrier, propagation.sampledKey, traceContext.sampled() ? "1" : "0"); } } }
/** * Idempotently sets correlation properties to hex representation of trace identifiers in this * context. */ void maybeReplaceTraceContext( TraceContext currentSpan, String previousTraceId, @Nullable String previousParentId, String previousSpanId ) { String traceId = currentSpan.traceIdString(); if (!traceId.equals(previousTraceId)) put("traceId", currentSpan.traceIdString()); String parentId = currentSpan.parentIdString(); if (parentId == null) { remove("parentId"); } else { boolean sameParentId = parentId.equals(previousParentId); if (!sameParentId) put("parentId", parentId); } String spanId = currentSpan.spanIdString(); if (!spanId.equals(previousSpanId)) put("spanId", spanId); }
@Override public boolean handle(TraceContext context, MutableSpan span) { if (!Boolean.TRUE.equals(context.sampled())) return true; Span.Builder builderWithContextData = Span.newBuilder() .traceId(context.traceIdString()) .parentId(context.parentIdString()) .id(context.spanIdString()); if (context.debug()) builderWithContextData.debug(true); converter.convert(span, builderWithContextData); spanReporter.report(builderWithContextData.build()); return true; }
@Override public void inject(TraceContext traceContext, C carrier) { setter.put(carrier, propagation.traceIdKey, traceContext.traceIdString()); setter.put(carrier, propagation.spanIdKey, traceContext.spanIdString()); String parentId = traceContext.parentIdString(); if (parentId != null) { setter.put(carrier, propagation.parentSpanIdKey, parentId); } if (traceContext.debug()) { setter.put(carrier, propagation.debugKey, "1"); } else if (traceContext.sampled() != null) { setter.put(carrier, propagation.sampledKey, traceContext.sampled() ? "1" : "0"); } } }