Package io.opentelemetry.api.trace
Interface TraceFlagsBuilder
public interface TraceFlagsBuilder
TraceFlagsBuilder is used to construct TraceFlags instances which satisfy the
https://www.w3.org/TR/trace-context-2/#trace-flags specification.
This is a simple usage example:
TraceFlags traceFlags = TraceFlags.builder().setSampled(true).build();
Implementation note: no new objects are created by the methods defined by this interface when
the default implementation, ImmutableTraceFlags, is used.
- Since:
- 1.60.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()ReturnsTraceFlagsrepresented by this object.setRandomTraceId(boolean isRandomTraceId) Returns an instance ofTraceFlagsBuilderwhich represents aTraceFlagsobject which has the RANDOM_TRACE_ID bit set if the argument istrueand the RANDOM_TRACE_ID bit cleared when the argument isfalse.setSampled(boolean isSampled) Returns an instance ofTraceFlagsBuilderwhich represents aTraceFlagsobject which has the SAMPLED bit set if the argument istrueand the SAMPLED bit cleared when the argument isfalse.
-
Method Details
-
setSampled
Returns an instance ofTraceFlagsBuilderwhich represents aTraceFlagsobject which has the SAMPLED bit set if the argument istrueand the SAMPLED bit cleared when the argument isfalse. Other bits remain unchanged. The operation does not modify this object.- Parameters:
isSampled- the new value for the SAMPLED bit- Returns:
- a
TraceFlagsBuilderobject representing the modifiedTraceFlags
-
setRandomTraceId
Returns an instance ofTraceFlagsBuilderwhich represents aTraceFlagsobject which has the RANDOM_TRACE_ID bit set if the argument istrueand the RANDOM_TRACE_ID bit cleared when the argument isfalse. Other bits remain unchanged. The operation does not modify this object.- Parameters:
isRandomTraceId- the new value for the RANDOM_TRACE_ID bit- Returns:
- a
TraceFlagsBuilderobject representing the modifiedTraceFlags
-
build
TraceFlags build()ReturnsTraceFlagsrepresented by this object.- Returns:
- a
TraceFlagsobject with the bits set as configured
-