Package brave.propagation.aws
Class AWSPropagation
java.lang.Object
brave.propagation.aws.AWSPropagation
- All Implemented Interfaces:
brave.propagation.Propagation<String>
Utility for working with Amazon Web Services Trace IDs, for example reading from headers or
environment variables.
x-amzn-trace-id is primarily for Amazon's X-Ray service, but it is
also integrated with AWS ALB, API Gateway and Lambda.
For example, if you are in a lambda environment, you can read the incoming context like this:
span = tracer.nextSpan(AWSPropagation.extractLambda());
Details
x-amzn-trace-id (and the lambda equivalent _X_AMZN_TRACE_ID) follows RFC 6265
style syntax (https://tools.ietf.org/html/rfc6265#section-2.2): fields are split on semicolon and
optional whitespace.
Description of the Root (or Self) field from AWS CLI help:
A trace_id consists of three numbers separated by hyphens. For example,
1-58406520-a006649127e371903a2de979. This includes:
- The version number, i.e. 1
- The time of the original request, in Unix epoch time, in 8 hexadecimal digits. For example, 10:00AM December 2nd, 2016 PST in epoch time is 1480615200 seconds, or 58406520 in hexadecimal.
- A 96-bit identifier for the trace, globally unique, in 24 hexadecimal digits.
-
Nested Class Summary
Nested classes/interfaces inherited from interface brave.propagation.Propagation
brave.propagation.Propagation.Getter<R extends Object,K extends Object>, brave.propagation.Propagation.KeyFactory<K extends Object>, brave.propagation.Propagation.RemoteGetter<R extends Object>, brave.propagation.Propagation.RemoteSetter<R extends Object>, brave.propagation.Propagation.Setter<R extends Object, K extends Object> -
Field Summary
FieldsFields inherited from interface brave.propagation.Propagation
B3_SINGLE_STRING, B3_STRING -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the currenttraceId(TraceContext)or null if not availablestatic brave.propagation.TraceContextOrSamplingFlagsLikeTraceContext.Extractor.extract(Object)except reading from a single field.static brave.propagation.TraceContextOrSamplingFlagsThis is used for extracting from the AWS lambda environment variable_X_AMZN_TRACE_ID.<R> brave.propagation.TraceContext.Extractor<R><R> brave.propagation.TraceContext.Injector<R>keys()returns the name of the header field: "x-amzn-trace-id"static StringtraceId(brave.propagation.TraceContext context) Used for log correlation ortag values
-
Field Details
-
FACTORY
public static final brave.propagation.Propagation.Factory FACTORY
-
-
Method Details
-
keys
returns the name of the header field: "x-amzn-trace-id"- Specified by:
keysin interfacebrave.propagation.Propagation<String>
-
injector
public <R> brave.propagation.TraceContext.Injector<R> injector(brave.propagation.Propagation.Setter<R, String> setter) - Specified by:
injectorin interfacebrave.propagation.Propagation<String>
-
currentTraceId
Returns the currenttraceId(TraceContext)or null if not available -
traceId
Used for log correlation ortag values- Returns:
- a formatted Root field like "1-58406520-a006649127e371903a2de979" or null if the
context was not created from an instance of
AWSPropagation.
-
extractor
public <R> brave.propagation.TraceContext.Extractor<R> extractor(brave.propagation.Propagation.Getter<R, String> getter) - Specified by:
extractorin interfacebrave.propagation.Propagation<String>
-
extractLambda
public static brave.propagation.TraceContextOrSamplingFlags extractLambda()This is used for extracting from the AWS lambda environment variable_X_AMZN_TRACE_ID.- See Also:
-
extract
LikeTraceContext.Extractor.extract(Object)except reading from a single field.
-