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

Add asynchronous tracing to Spring Boot Autoconfigure WithSpanAspect #2618

Merged
merged 2 commits into from
Mar 29, 2021

Conversation

HaloFour
Copy link
Contributor

Updates the WithSpanAspect in Spring Boot Autoconfigure module to support asynchronous return types. Refactors the MethodSpanStrategies implementations from OpenTelemetry Annotations module to enable sharing between instrumentation projects.

Open question: Should the async method strategy machinery belong in the instrumentation-api module or would it be better suited in a separate AOP module?

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

👍

@@ -2,4 +2,4 @@
* Provides implementations of strategies for tracing methods that return asynchronous and reactive
* values so that the span can be ended when the asynchronous operation completes.
*/
package io.opentelemetry.javaagent.instrumentation.otelannotations.async;
package io.opentelemetry.instrumentation.api.tracer.async;
Copy link
Member

Choose a reason for hiding this comment

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

maybe .async -> .future or .promise

.async feels a bit general

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd probably gravitate to reactive but that's probably as general as async is. Of your suggestions I think future probably fits better in the Java ecosystem.

Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

WDYT about renaming MethodSpanStrategy/-ies to AsyncSpanEndStrategy/-ies? (or something similar that emphasises the asynchronous nature of this code)

@trask
Copy link
Member

trask commented Mar 29, 2021

WDYT about renaming MethodSpanStrategy/-ies to AsyncSpanEndStrategy/-ies? (or something similar that emphasises the asynchronous nature of this code)

that sounds nice, and if we don't find an AsyncSpanEndStrategy, we can handle the default synchronous case without a strategy, e.g.

  public Object end(Context context, Class<?> returnType, Object returnValue) {
    ...
    AsyncSpanEndStrategy asyncSpanEndStrategy = asyncSpanEndStrategies.resolveStrategy(returnType);
    if (asyncSpanEndStrategy != null) {
      return asyncSpanEndStrategy.end(this, context, returnValue);
    }
    end(context);
    return returnValue;
  }

@HaloFour
Copy link
Contributor Author

That sounds good to me. If the interface is AsyncSpanEndStrategy does it make sense for the package name to remain async then?

@trask
Copy link
Member

trask commented Mar 29, 2021

If the interface is AsyncSpanEndStrategy does it make sense for the package name to remain async then?

Ya, let's keep it async unless anyone else has thoughts.

@trask
Copy link
Member

trask commented Mar 29, 2021

@HaloFour looks like it needs a ./gradlew spotlessApply

@trask trask merged commit b0d2740 into open-telemetry:main Mar 29, 2021
@trask
Copy link
Member

trask commented Mar 29, 2021

🚢

@HaloFour
Copy link
Contributor Author

Shweet! Looking at the changes I think that maybe Jdk8AsyncEndStrategy could have been named Jdk8AsyncSpanEndStrategy instead. Refactor fumble on my part. I could open a follow up PR to change it. At least the class is package-private so it doesn't really matter.

@trask
Copy link
Member

trask commented Mar 30, 2021

I could open a follow up PR to change it. At least the class is package-private so it doesn't really matter.

👍 (not a problem even if it was public, as none of the instrumentation APIs have been declared stable yet)

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.

None yet

3 participants