public TraceContextOrSamplingFlags sampled(boolean sampled) { int flags = InternalPropagation.sampled(sampled, value.flags); if (flags == value.flags) return this; // save effort if no change return withFlags(flags); }
/** @deprecated do not use object variant.. only set when you have a sampling decision */ @Deprecated public TraceContextOrSamplingFlags sampled(@Nullable Boolean sampled) { if (sampled != null) return sampled(sampled.booleanValue()); int flags = value.flags; flags &= ~FLAG_SAMPLED_SET; flags &= ~FLAG_SAMPLED; if (flags == value.flags) return this; // save effort if no change return withFlags(flags); }
/** Returns an immutable result from the values currently in the builder */ public final TraceContextOrSamplingFlags build() { final TraceContextOrSamplingFlags result; if (!extra.isEmpty() && type == 1) { // move extra to the trace context TraceContext context = (TraceContext) value; if (context.extra().isEmpty()) { context = InternalPropagation.instance.withExtra(context, ensureImmutable(extra)); } else { context = InternalPropagation.instance.withExtra(context, concatImmutableLists(context.extra(), extra)); } result = new TraceContextOrSamplingFlags(type, context, emptyList()); } else { // make sure the extra data is immutable and unmodifiable result = new TraceContextOrSamplingFlags(type, value, ensureImmutable(extra)); } if (!sampledLocal) return result; // save effort if no change return result.withFlags(value.flags | FLAG_SAMPLED_LOCAL); }
public TraceContextOrSamplingFlags sampled(boolean sampled) { int flags = InternalPropagation.sampled(sampled, value.flags); if (flags == value.flags) return this; // save effort if no change return withFlags(flags); }
/** @deprecated do not use object variant.. only set when you have a sampling decision */ @Deprecated public TraceContextOrSamplingFlags sampled(@Nullable Boolean sampled) { if (sampled != null) return sampled(sampled.booleanValue()); int flags = value.flags; flags &= ~FLAG_SAMPLED_SET; flags &= ~FLAG_SAMPLED; if (flags == value.flags) return this; // save effort if no change return withFlags(flags); }
/** Returns an immutable result from the values currently in the builder */ public final TraceContextOrSamplingFlags build() { final TraceContextOrSamplingFlags result; if (!extra.isEmpty() && type == 1) { // move extra to the trace context TraceContext context = (TraceContext) value; if (context.extra().isEmpty()) { context = InternalPropagation.instance.withExtra(context, ensureImmutable(extra)); } else { context = InternalPropagation.instance.withExtra(context, concatImmutableLists(context.extra(), extra)); } result = new TraceContextOrSamplingFlags(type, context, emptyList()); } else { // make sure the extra data is immutable and unmodifiable result = new TraceContextOrSamplingFlags(type, value, ensureImmutable(extra)); } if (!sampledLocal) return result; // save effort if no change return result.withFlags(value.flags | FLAG_SAMPLED_LOCAL); }