-
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
Merged
dalexandrov
merged 11 commits into
helidon-io:helidon-3.x
from
dalexandrov:6970_OpenTracingSpan
Jun 15, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bfb1a5d
Fix OpenTracingSpan Baggage propagation issue
dalexandrov 13add8b
Correct context usage for openTelemetery
dalexandrov edb1b55
Move tests to integrations
dalexandrov 49b97d4
Move tests to integrations
dalexandrov f1f7155
Finalize test
dalexandrov f75bed4
Finalize test
dalexandrov 1438af8
Finalize test
dalexandrov b61547d
Finalize test
dalexandrov faaa4ec
Address comments
dalexandrov 86cb069
Address Tomas comments
dalexandrov 23534ee
Remove redundant stuff
dalexandrov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2023 Oracle and/or its affiliates. | ||
|
||
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 | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.helidon.applications</groupId> | ||
<artifactId>helidon-se</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
<relativePath>../../../applications/se/pom.xml</relativePath> | ||
</parent> | ||
<groupId>io.helidon.tests.integration</groupId> | ||
<artifactId>helidon-tests-integration-tracer-baggage</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.tracing</groupId> | ||
<artifactId>helidon-tracing</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.tracing</groupId> | ||
<artifactId>helidon-tracing-jaeger</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
80 changes: 80 additions & 0 deletions
80
...ntegration/gh-6970/src/test/java/io/helidon/tests/integration/tracerbaggage/MainTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2023 Oracle and/or its affiliates. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.helidon.tests.integration.tracerbaggage; | ||
|
||
import io.helidon.config.Config; | ||
import io.helidon.tracing.HeaderConsumer; | ||
import io.helidon.tracing.HeaderProvider; | ||
import io.helidon.tracing.Span; | ||
import io.helidon.tracing.Tracer; | ||
import io.helidon.tracing.TracerBuilder; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.TreeMap; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.hasItem; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
class MainTest { | ||
|
||
public static final String KEY = "fubar"; | ||
public static final String VALUE = "1"; | ||
|
||
@BeforeAll | ||
static void prepareTracer() { | ||
Config config = Config.create(); | ||
|
||
TracerBuilder.create(config.get("tracing")) | ||
.serviceName("helidon-service") | ||
.registerGlobal(true) | ||
.build(); | ||
|
||
|
||
} | ||
|
||
/** | ||
* Test for: https://github.com/helidon-io/helidon/issues/6970 | ||
*/ | ||
@Test | ||
void baggageCanaryMinimal() { | ||
Tracer tracer = Tracer.global(); | ||
tomas-langer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Span span = tracer.spanBuilder("baggageCanaryMinimal").start(); | ||
// Set baggage and confirm that it's known in the span | ||
span.baggage(KEY, VALUE); | ||
assertThat(span.baggage(KEY).orElse(null), is(VALUE)); | ||
|
||
// Inject the span (context) into the consumer | ||
HeaderConsumer consumer = HeaderConsumer | ||
.create(new TreeMap<>(String.CASE_INSENSITIVE_ORDER)); | ||
tracer.inject(span.context(), HeaderProvider.empty(), consumer); | ||
|
||
// Check baggage propagated | ||
List<String> result = new ArrayList<>(); | ||
consumer.keys().forEach(result::add); | ||
assertThat(result, hasItem(containsString(KEY))); | ||
|
||
//Check baggage value | ||
String fubar = result.stream().filter(e -> e.contains(KEY)).findFirst().orElseThrow(); | ||
assertThat(consumer.get(fubar).orElseThrow(), is(VALUE)); | ||
span.end(); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
tests/integration/gh-6970/src/test/resources/application.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Copyright (c) 2023 Oracle and/or its affiliates. | ||
# | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
tracing: | ||
service: "helidon-service" | ||
protocol: "https" | ||
host: "jaeger" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,8 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. Why is the resulting |
||
return this; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!