Unlike {@link #CLIENT}, messaging spans never share a span ID. For example, the {@link * #CONSUMER} of the same message has {@link TraceContext#parentId()} set to this span's {@link @@ -62,7 +63,7 @@ public enum Kind { /** * When present, {@link #start()} is the moment a consumer received a message from an origin. A * duration between {@link #start()} and {@link #finish()} may imply a processing backlog. while - * {@link #remoteServiceName(String)} indicates the origin, such as a broker. + * {@link #remoteEndpoint(Endpoint)} indicates the origin, such as a broker. * *
Unlike {@link #SERVER}, messaging spans never share a span ID. For example, the {@link
* #PRODUCER} of this message is the {@link TraceContext#parentId()} of this span.
@@ -136,6 +137,18 @@ public enum Kind {
// multi-catch. In practice, you should always at least catch RuntimeException and Error.
public abstract Span error(Throwable throwable);
+ /**
+ * @deprecated Since 5.0, use {@link #remoteServiceName(String)} {@link #remoteIpAndPort(String,
+ * int)}.
+ */
+ @Deprecated public Span remoteEndpoint(Endpoint endpoint) {
+ if (endpoint == null) return this;
+ if (endpoint.serviceName() != null) remoteServiceName(endpoint.serviceName());
+ String ip = endpoint.ipv6() != null ? endpoint.ipv6() : endpoint.ipv4();
+ remoteIpAndPort(ip, endpoint.portAsInt());
+ return this;
+ }
+
/**
* Lower-case label of the remote node in the service graph, such as "favstar". Do not set if
* unknown. Avoid names with variables or unique identifiers embedded.
diff --git a/brave/src/main/java/brave/Tags.java b/brave/src/main/java/brave/Tags.java
index 1936c31601..f89ecde5ba 100644
--- a/brave/src/main/java/brave/Tags.java
+++ b/brave/src/main/java/brave/Tags.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2024 The OpenZipkin Authors
+ * Copyright 2013-2020 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -33,13 +33,7 @@ public final class Tags {
*/
public static final Tag Since 5.12, this is deprecated for using {@link zipkin2.reporter.brave.ZipkinSpanHandler}
+ * in the io.zipkin.reporter2:zipkin-reporter-brave
+ * library.
+ *
+ * For example, here's how to batch send spans via HTTP to a Zipkin-compatible endpoint:
+ * For example, if you have a need to know the specific request's country code, you can
+ * For example, if you have a need to know the a specific request's country code, you can
* propagate it through the trace as HTTP headers.
* This is different than {@link BaggageField#getAll(TraceContext)}, as propagation keys may be
+ * different than {@linkplain BaggageField#name() baggage field names}.
*
* @param propagation used to extract configuration
* @return a list of remote propagation key names used for trace context and baggage.
@@ -323,7 +327,7 @@ static final class BaggageInjector Ex. When the state is a simple string, this will just use the request value directly.
+ * {@linkplain BaggageFields#isDynamic() dynamic values} will need to perform some decoding,
+ * such as splitting on comma and equals.
+ *
* @param valueUpdater used to assign {@link BaggageField} values.
+ * @param request the parameter of {@link Extractor#extract(Object)}
* @param value a non-{@code null} result of {@link Getter#get(Object, Object)}
* @see #extractKeyNames()
*/
- boolean decode(ValueUpdater valueUpdater, String value);
+ boolean decode(ValueUpdater valueUpdater, Object request, String value);
/**
* Encodes any state to a request value used by {@link Setter#put(Object, Object, String)}. When
@@ -91,5 +98,5 @@ public interface BaggageCodec {
* @return an input to {@link Setter#put(Object, Object, String)}
* @see #injectKeyNames()
*/
- @Nullable String encode(Map Here's how to integrate:
+ *
+ * First, override {@link Propagation.Factory#get()} with your actual implementation. Then,
+ * dispatch {@link Propagation.Factory#create(KeyFactory)} to your implementation via {@link
+ * #create(Propagation, KeyFactory)}:
+ *
+ * This is internal, and will be removed in Brave 6. However, it won't be removed
+ * before Brave 6. If you wish to use this, use "maven-shade-plugin" with the following
+ * configuration, or something similar.
+ *
+ * {@code
* // Assume a framework interceptor uses this method to set the inbound span as current
- * try (SpanInScope scope = tracer.withSpanInScope(span)) {
+ * try (SpanInScope ws = tracer.withSpanInScope(span)) {
* return inboundRequest.invoke();
* // note: try-with-resources closes the scope *before* the catch block
* } catch (RuntimeException | Error e) {
@@ -414,7 +438,7 @@ Span _toSpan(@Nullable TraceContext parent, TraceContext context) {
* // An unrelated framework interceptor can now lookup the correct parent for outbound requests
* Span parent = tracer.currentSpan()
* Span span = tracer.nextSpan().name("outbound").start(); // parent is implicitly looked up
- * try (SpanInScope scope = tracer.withSpanInScope(span)) {
+ * try (SpanInScope ws = tracer.withSpanInScope(span)) {
* return outboundRequest.invoke();
* // note: try-with-resources closes the scope *before* the catch block
* } catch (RuntimeException | Error e) {
diff --git a/brave/src/main/java/brave/Tracing.java b/brave/src/main/java/brave/Tracing.java
index a92c0b1117..cad13e7127 100644
--- a/brave/src/main/java/brave/Tracing.java
+++ b/brave/src/main/java/brave/Tracing.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2024 The OpenZipkin Authors
+ * Copyright 2013-2023 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -14,6 +14,7 @@
package brave;
import brave.baggage.BaggageField;
+import brave.handler.FinishedSpanHandler;
import brave.handler.MutableSpan;
import brave.handler.SpanHandler;
import brave.internal.Nullable;
@@ -36,6 +37,8 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
+import zipkin2.reporter.Reporter;
+import zipkin2.reporter.brave.ZipkinSpanHandler;
/**
* This provides utilities needed for trace instrumentation. For example, a {@link Tracer}.
@@ -62,6 +65,9 @@ public static Builder newBuilder() {
*/
public abstract Propagation
{@code
+ * // Configure a reporter, which controls how often spans are sent
+ * // (this dependency is io.zipkin.reporter2:zipkin-sender-okhttp3)
+ * sender = OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans");
+ * // (this dependency is io.zipkin.reporter2:zipkin-reporter-brave)
+ * zipkinSpanHandler = AsyncZipkinSpanHandler.create(sender); // don't forget to close!
+ *
+ * // Create a tracing component with the service name you want to see in Zipkin.
+ * tracing = Tracing.newBuilder()
+ * .localServiceName("my-service")
+ * .addSpanHandler(zipkinSpanHandler)
+ * .build();
+ * }
+ *
+ * @see #addSpanHandler(SpanHandler)
+ * @deprecated Since 5.12, use {@link #addSpanHandler(SpanHandler)} with a
+ * {@link zipkin2.reporter.brave.ZipkinSpanHandler}
+ */
+ @Deprecated public Builder spanReporter(Reporter{@code
* import brave.baggage.BaggagePropagationConfig.SingleBaggageField;
@@ -83,7 +84,6 @@
* );
* }
*
- * @param {@code
+ * @Override public Propagation
+ *
+ * {@code
+ *
+ *
+ * @since 5.12
+ * @deprecated As of Brave 5.18, throw an {@link UnsupportedOperationException} in
+ * {@link #create(Propagation, KeyFactory)} instead of implementing it.
+ */
+@Deprecated
+public final class StringPropagationAdapter