use of brave.propagation.TraceContext in project brave by openzipkin.
the class MutableSpanMapTest method remove_resolvesHashCodeCollisions.
@Test
public void remove_resolvesHashCodeCollisions() {
// intentionally clash on hashCode, but not equals
TraceContext context1 = context.toBuilder().spanId(1).build();
TraceContext context2 = context.toBuilder().spanId(-2L).build();
// sanity check
assertThat(context1.hashCode()).isEqualTo(context2.hashCode());
assertThat(context1).isNotEqualTo(context2);
map.getOrCreate(context1);
map.getOrCreate(context2);
map.remove(context1);
assertThat(map.delegate.keySet()).extracting(o -> ((Reference) o).get()).containsOnly(context2);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class AWSPropagation method currentTraceId.
/**
* Returns the current {@link #traceId(TraceContext)} or null if not available
*/
@Nullable
public static String currentTraceId() {
Tracing tracing = Tracing.current();
if (tracing == null)
return null;
TraceContext context = tracing.currentTraceContext().get();
if (context == null)
return null;
return traceId(context);
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class AWSPropagationTest method traceIdWhenPassThrough.
@Test
public void traceIdWhenPassThrough() {
carrier.put("x-amzn-trace-id", "Robot=Hello;Self=1-582113d1-1e48b74b3603af8479078ed6; " + "Root=1-58211399-36d228ad5d99923122bbe354; " + "TotalTimeSoFar=112ms;CalledFrom=Foo");
TraceContext context = contextWithPassThrough();
assertThat(AWSPropagation.traceId(context)).isEqualTo("1-58211399-36d228ad5d99923122bbe354");
}
use of brave.propagation.TraceContext in project brave by openzipkin.
the class AWSPropagationTest method traceId_null_if_not_aws.
@Test
public void traceId_null_if_not_aws() {
TraceContext notAWS = sampledContext.toBuilder().extra(Collections.emptyList()).build();
assertThat(AWSPropagation.traceId(notAWS)).isNull();
}
Aggregations