Package com.dynatrace.agent.api
Class TraceContext
java.lang.Object
com.dynatrace.agent.api.TraceContext
Represents a W3C Trace Context containing
traceparent and tracestate headers.
This object is returned by Dynatrace.generateTraceContext(String, String) and provides access to validated
traceparent and tracestate values that can be used to manually tag HTTP requests for distributed tracing.
Usage example:
TraceContext traceContext = Dynatrace.generateTraceContext(request.header("traceparent"), request.header("tracestate"));
if(traceContext != null) {
request = request.newBuilder()
// maybe relevant for other libraries: addHeader or setHeader
.addHeader("traceparent", traceContext.getTraceparent())
.addHeader("tracestate", traceContext.getTracestate())
.build();
}
- Since:
- 8.333
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTraceContext(String traceparent, String tracestate) Generates a W3C Trace Context containingtraceparentandtracestateheaders. -
Method Summary
Modifier and TypeMethodDescriptionReturns thetraceparentheader value.Returns thetracestateheader value.
-
Constructor Details
-
TraceContext
Generates a W3C Trace Context containingtraceparentandtracestateheaders.- Parameters:
traceparent- thetraceparentheader valuetracestate- thetracestateheader value
-
-
Method Details
-
getTraceparent
Returns thetraceparentheader value.The traceparent header is a W3C standard header that contains trace-id, parent-id (span-id), and trace-flags. This value can be used as the value for the "traceparent" HTTP header.
- Returns:
- the
traceparentheader value, never null
-
getTracestate
Returns thetracestateheader value.The tracestate header is a W3C standard header that contains vendor-specific trace information. This value can be used as the value for the "tracestate" HTTP header.
- Returns:
- the
tracestateheader value, never null (may be empty string)
-