-
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
Changes from 10 commits
bfb1a5d
13add8b
edb1b55
49b97d4
f1f7155
f75bed4
1438af8
b61547d
faaa4ec
86cb069
23534ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?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> | ||
|
||
<properties> | ||
<mainClass>io.helidon.tests.integration.tracerbaggage.Main</mainClass> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.webserver</groupId> | ||
<artifactId>helidon-webserver</artifactId> | ||
</dependency> | ||
<dependency> | ||
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. not needed 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. Removed! |
||
<groupId>io.helidon.media</groupId> | ||
<artifactId>helidon-media-jsonp</artifactId> | ||
</dependency> | ||
<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> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
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. not needed (probably the whole 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. Removed! |
||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-libs</id> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.*; | ||
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. star imports are not permitted. Please use our code style. 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. Something's wrong with my Idea after the update... Fixed! |
||
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 startTheServer() { | ||
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. method name is wrong 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. Renamed! |
||
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(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# 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. | ||
# | ||
server: | ||
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. server section is no longer needed 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. Removed |
||
port: 8080 | ||
host: 0.0.0.0 | ||
|
||
tracing: | ||
service: "helidon-service" | ||
protocol: "https" | ||
host: "jaeger" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. wrong formatting, please keep same code style ( 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. done |
||
.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; | ||
} | ||
|
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!