Skip to content

fix: replace Span.makeCurrent() with Span.asContextElement() #1237

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

Merged
merged 6 commits into from
Feb 25, 2025

Conversation

lauzadis
Copy link
Contributor

@lauzadis lauzadis commented Feb 7, 2025

Issue #

Description of changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lauzadis lauzadis requested a review from a team as a code owner February 7, 2025 20:32
@lauzadis lauzadis added no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. and removed no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. labels Feb 7, 2025

This comment has been minimized.

3 similar comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

Affected Artifacts

Changed in size
Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
aws-signing-default-jvm.jar 53,497 51,946 1,551 2.99%
runtime-core-jvm.jar 825,504 818,814 6,690 0.82%
telemetry-api-jvm.jar 117,168 116,800 368 0.32%
identity-api-jvm.jar 29,491 29,469 22 0.07%
http-client-jvm.jar 317,183 317,120 63 0.02%
telemetry-provider-otel-jvm.jar 30,176 30,186 -10 -0.03%

Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

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

Question: Do we need to update our Micrometer implementation too?

@@ -71,7 +71,7 @@ public suspend inline fun <R> withSpan(
// or else traces may be disconnected from their parent
val updatedCtx = coroutineContext[TelemetryProviderContext]?.provider?.contextManager?.current()
val telemetryCtxElement = (updatedCtx?.let { TelemetryContextElement(it) } ?: coroutineContext[TelemetryContextElement]) ?: EmptyCoroutineContext
withContext(context + TraceSpanContext(span) + telemetryCtxElement) {
withContext(context + TraceSpanContext(span) + telemetryCtxElement + span.asContextElement()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set up tests to confirm this is working as expected?

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 a very complex setup, involving two Docker containers and a lot of visual inspection. I'm not sure setting up unit tests would be worth the effort

"type": "bugfix",
"description": "Fix OpenTelemetry span concurrency by using Span.asContextElement() instead of Span.makeCurrent()",
"issues": [
"https://github.com/smithy-lang/smithy-kotlin/issues/1211"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We could mention the issue in the pull request description as well

@lauzadis
Copy link
Contributor Author

@ianbotsf Question: Do we need to update our Micrometer implementation too?

No we don't, because Micrometer doesn't have a TracerProvider implementation

@lauzadis lauzadis merged commit 09838a7 into main Feb 25, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants