Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test to prove #1306 #1336

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 The OpenZipkin Authors
* Copyright 2013-2023 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion brave/src/main/java/brave/handler/SpanHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 The OpenZipkin Authors
* Copyright 2013-2023 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down
22 changes: 21 additions & 1 deletion brave/src/test/java/brave/TracerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 The OpenZipkin Authors
* Copyright 2013-2022 The OpenZipkin Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -37,9 +37,12 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import org.junit.After;
import org.junit.Test;
import org.mockito.Mockito;

import zipkin2.Endpoint;
import zipkin2.reporter.Reporter;

Expand Down Expand Up @@ -226,6 +229,7 @@ public class TracerTest {
@Test public void join_createsChildWhenUnsupportedByPropagation() {
tracer = Tracing.newBuilder()
.propagationFactory(new Propagation.Factory() {
@Override
@Deprecated public <K> Propagation<K> create(Propagation.KeyFactory<K> keyFactory) {
return B3Propagation.FACTORY.create(keyFactory);
}
Expand Down Expand Up @@ -1092,6 +1096,22 @@ private static void simulateInProcessPropagation(Tracer tracer1, Tracer tracer2)
assertThat(toSpan.extra()).isNotEmpty();
}

@Test public void toSpan_flushedAfterFetch() throws InterruptedException, ExecutionException {
propagationFactory = baggageFactory;
TraceContext parent = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(true).build();
TraceContext incoming = TraceContext.newBuilder().traceId(1L).spanId(3L).parentId(2L).sampled(true).build();

tracer.pendingSpans.getOrCreate(parent, incoming, false);
Tracer spiedTracer = Mockito.spy(tracer);
Mockito.doAnswer(i -> {
//Simulate a concurrent call flushing the span at the beginning of this method's execution
tracer.pendingSpans.flush(incoming);
return i.callRealMethod();
}).when(spiedTracer)._toSpan(Mockito.any(TraceContext.class), Mockito.any(TraceContext.class));

spiedTracer.toSpan(incoming);
}

@Test public void currentSpan_sameContextReference() {
Span span = tracer.newTrace();
try (SpanInScope ws = tracer.withSpanInScope(span)) {
Expand Down
Loading