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

[3.x ] - Fix OpenTracingSpan Baggage propagation issue #6987

Merged
merged 11 commits into from
Jun 15, 2023

Conversation

dalexandrov
Copy link
Contributor

Resolves #6970

@dalexandrov dalexandrov added tracing 3.x Issues for 3.x version branch telemetry labels Jun 12, 2023
@dalexandrov dalexandrov self-assigned this Jun 12, 2023
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 12, 2023
@dalexandrov dalexandrov marked this pull request as ready for review June 14, 2023 11:57
// Check baggage propagated
List<String> result = new ArrayList<>();
consumer.keys().forEach(result::add);
assertThat(result, hasItem(containsString("fubar")));
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added value test

@dalexandrov dalexandrov requested a review from tomas-langer June 14, 2023 14:30
@@ -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();
Copy link
Member

@spericas spericas Jun 14, 2023

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?

Copy link
Contributor Author

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();
Copy link
Member

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();

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?

Copy link
Contributor Author

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);

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.

Copy link
Contributor Author

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)

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'

Copy link
Contributor Author

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)

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'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated.

Copy link

@RickyFrost RickyFrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See detail comments

@dalexandrov
Copy link
Contributor Author

See detail comments

Looks like you have reviewed something outdated...

trentjeff
trentjeff previously approved these changes Jun 14, 2023
tests/integration/gh-6970/.dockerignore Outdated Show resolved Hide resolved
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Member

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

package io.helidon.tests.integration.tracerbaggage;

import io.helidon.config.Config;
import io.helidon.tracing.*;
Copy link
Member

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.

Copy link
Contributor Author

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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method name is wrong

Copy link
Contributor Author

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:
Copy link
Member

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

Copy link
Contributor Author

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))
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

</properties>

<dependencies>
<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
</dependency>
<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Copy link
Member

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


<build>
<plugins>
<plugin>
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

@dalexandrov dalexandrov requested a review from tomas-langer June 15, 2023 16:52
@RickyFrost
Copy link

This fix is solving the wrong problem. See today's update in #6970

@dalexandrov dalexandrov merged commit d785d8b into helidon-io:helidon-3.x Jun 15, 2023
@dalexandrov dalexandrov deleted the 6970_OpenTracingSpan branch June 15, 2023 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues for 3.x version branch OCA Verified All contributors have signed the Oracle Contributor Agreement. telemetry tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not able to propagate baggage in OpenTracingSpan
5 participants