-
Notifications
You must be signed in to change notification settings - Fork 566
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
[3.x ] - Fix OpenTracingSpan Baggage propagation issue #6987
[3.x ] - Fix OpenTracingSpan Baggage propagation issue #6987
Conversation
// Check baggage propagated | ||
List<String> result = new ArrayList<>(); | ||
consumer.keys().forEach(result::add); | ||
assertThat(result, hasItem(containsString("fubar"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth testing the value also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A stronger test would be to use Runtime
to spawn another process with a ClientMain
that calls into the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added value test
@@ -118,6 +118,7 @@ public Optional<String> baggage(String key) { | |||
// Check if OTEL Context is already available in Global Helidon Context. | |||
// If not – use Current context. | |||
private static Context getContext() { | |||
Context.current().makeCurrent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an expert in the API, but this line gives me pause. We are making current something that is current? And the scope that is returned (which presumably needs closing at some point) is ignored? Can we explain this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a leftover. Now removed!
@@ -104,7 +104,7 @@ public Span baggage(String key, String value) { | |||
Baggage.builder() | |||
.put(key, value) | |||
.build() | |||
.storeInContext(getContext()) | |||
.storeInContext(getContext().with(delegate)) | |||
.makeCurrent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the resulting Scope
ignored here?
@@ -66,7 +64,7 @@ public void status(Status status) { | |||
|
|||
@Override | |||
public SpanContext context() { | |||
return context; | |||
return Span.current().orElseThrow().context(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return the wrapped delegate.context() here? (i.e. the line removed in above constructor). Aren't you unnecessarily risking a throw here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated.
// Inject the span (context) into the consumer | ||
final var consumer = HeaderConsumer | ||
.create(new TreeMap<>(String.CASE_INSENSITIVE_ORDER)); | ||
tracer.inject(Span.current().orElseThrow().context(), HeaderProvider.empty(), consumer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Span.current()....context() here works around the issue of the bug. span.context() is needed here to really prove the problem has been fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated.
tracer.inject(Span.current().orElseThrow().context(), HeaderProvider.empty(), consumer); | ||
|
||
|
||
// Confirm that baggage was NOT propagated (the bug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was appropriate for the standalone test case showing the issue, but as a test for the fix remove 'NOT'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated.
.create(new TreeMap<>(String.CASE_INSENSITIVE_ORDER)); | ||
tracer.inject(span.context(), HeaderProvider.empty(), consumer); | ||
|
||
// Confirm that baggage was NOT propagated (the bug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was appropriate for the standalone test case showing the issue, but as a test for the fix remove 'NOT'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See detail comments
Looks like you have reviewed something outdated... |
tests/integration/gh-6970/pom.xml
Outdated
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really needed for atest (this is only useful when running from command line or packaging to docker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not removed - comment was about copy libs
tests/integration/gh-6970/src/main/java/io/helidon/tests/integration/tracerbaggage/Main.java
Outdated
Show resolved
Hide resolved
tests/integration/gh-6970/src/main/resources/logging.properties
Outdated
Show resolved
Hide resolved
...s/integration/gh-6970/src/test/java/io/helidon/tests/integration/tracerbaggage/MainTest.java
Show resolved
Hide resolved
package io.helidon.tests.integration.tracerbaggage; | ||
|
||
import io.helidon.config.Config; | ||
import io.helidon.tracing.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
star imports are not permitted. Please use our code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something's wrong with my Idea after the update... Fixed!
public static final String VALUE = "1"; | ||
|
||
@BeforeAll | ||
static void startTheServer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method name is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed!
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
server: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server section is no longer needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -104,7 +104,7 @@ public Span baggage(String key, String value) { | |||
Baggage.builder() | |||
.put(key, value) | |||
.build() | |||
.storeInContext(getContext()) | |||
.storeInContext(getContext().with(delegate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong formatting, please keep same code style (.with(delegate)
should be on a new line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
</properties> | ||
|
||
<dependencies> | ||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
tests/integration/gh-6970/pom.xml
Outdated
<groupId>io.helidon.webserver</groupId> | ||
<artifactId>helidon-webserver</artifactId> | ||
</dependency> | ||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
tests/integration/gh-6970/pom.xml
Outdated
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not removed - comment was about copy libs
tests/integration/gh-6970/pom.xml
Outdated
|
||
<build> | ||
<plugins> | ||
<plugin> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed (probably the whole build
section, if the tests are running)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
This fix is solving the wrong problem. See today's update in #6970 |
Resolves #6970