Propagation<K>public final class ExtraFieldPropagation<K> extends Object implements Propagation<K>
For example, if you are in a Cloud Foundry environment, you might want to pass the request ID:
// when you initialize the builder, define the extra field you want to propagate
tracingBuilder.propagationFactory(
ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "x-vcap-request-id")
);
// later, you can tag that request ID or use it in log correlation
requestId = ExtraFieldPropagation.current("x-vcap-request-id");
You may also need to propagate a trace context you aren't using. For example, you may be in an Amazon Web Services environment, but not reporting data to X-Ray. To ensure X-Ray can co-exist correctly, pass-through its tracing header like so.
tracingBuilder.propagationFactory(
ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "x-amzn-trace-id")
);
Propagation.Getter<C,K>, Propagation.KeyFactory<K>, Propagation.Setter<C,K>B3_STRING| Modifier and Type | Method | Description |
|---|---|---|
static String |
current(String name) |
Returns the value of the field with the specified key or null if not available
|
<C> TraceContext.Extractor<C> |
extractor(Propagation.Getter<C,K> getter) |
|
static String |
get(TraceContext context,
String name) |
Returns the value of the field with the specified key or null if not available
|
<C> TraceContext.Injector<C> |
injector(Propagation.Setter<C,K> setter) |
Replaces a propagated field with the given value.
|
List<K> |
keys() |
The propagation fields defined.
|
static Propagation.Factory |
newFactory(Propagation.Factory delegate,
String... names) |
Wraps an underlying propagation implementation, pushing one or more fields
|
static Propagation.Factory |
newFactory(Propagation.Factory delegate,
Collection<String> names) |
Wraps an underlying propagation implementation, pushing one or more fields
|
public static Propagation.Factory newFactory(Propagation.Factory delegate, String... names)
public static Propagation.Factory newFactory(Propagation.Factory delegate, Collection<String> names)
@Nullable public static String current(String name)
@Nullable public static String get(TraceContext context, String name)
public List<K> keys()
PropagationPropagation.Setter.put(Object, Object, String).
For example, if the carrier is a single-use or immutable request object, you don't need to clear fields as they couldn't have been set before. If it is a mutable, retryable object, successive calls should clear these fields first.
keys in interface Propagation<K>public <C> TraceContext.Injector<C> injector(Propagation.Setter<C,K> setter)
PropagationHttpURLConnection would be the method reference
URLConnection.addRequestProperty(String, String)injector in interface Propagation<K>setter - invoked for each propagation key to add.public <C> TraceContext.Extractor<C> extractor(Propagation.Getter<C,K> getter)
extractor in interface Propagation<K>getter - invoked for each propagation key to get.Copyright © 2017 OpenZipkin. All rights reserved.