-
Notifications
You must be signed in to change notification settings - Fork 79
Draft: Add instrumentation for otel span annotations #1348
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
base: main
Are you sure you want to change the base?
Draft: Add instrumentation for otel span annotations #1348
Conversation
|
@Kleszczu98 hi. The title of this still says it's a draft PR, but it's not marked as such. Please remove the word Draft from the title if it's ready for review, or mark it truly as draft by clicking "Convert to draft". You'll will also need to sign the Contributor License Agreement (CLA). Thanks! |
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.
Are we aware of a use case that requires tracing a constructor? It sounds a bit of an edge case to me. If there's no foreseeable usage right now, I'd prefer to leave it for a future PR.
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.
Ok, i will remove the constructor implementation and focus on just the normal method case to simplify the PR.
| @Advice.OnMethodEnter(suppress = Throwable::class) | ||
| fun onEnter( | ||
| @Advice.AllArguments args: Array<Any?>, | ||
| @Advice.Origin method: Method |
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.
I'd like to follow best practices from the upstream instrumentation, such as avoiding using @Advice.Origin Method. In this case it seems like we can just get the method name by using @Advice.Origin("#m") String methodName.
| @JvmStatic | ||
| @Advice.OnMethodEnter(suppress = Throwable::class) | ||
| fun onEnter( | ||
| @Advice.AllArguments args: Array<Any?>, |
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.
I'm not faimilar with @WithSpan, though I'm curious why it might need all the method's arguments?
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.
I found the @AddingSpanAttributes annotation but it seems i might've misunderstood it's function.
It is not mentioned in the linked documentation so perhaps I should remove this as well and stick to @WithSpan and @SpanAttribute ? It covers all the most common use cases already.
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.
I see. I also don't see it in the docs so it should be fine to leave it out, at least for now. I'll cc @breedx-splk in case he's more familiar with it to make sure we're not missing something important.
- Removed constructor implementation for now
- Applied @Advice.Origin("#m") in AddingSpanAttributesMethodAdvice.kt
- Added basic test for a start
- Generated apiDump
- Ran spotlessApply
- Ran check
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1348 +/- ##
==========================================
- Coverage 64.17% 62.33% -1.84%
==========================================
Files 153 164 +11
Lines 3059 3181 +122
Branches 315 328 +13
==========================================
+ Hits 1963 1983 +20
- Misses 1007 1105 +98
- Partials 89 93 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Example byteBuddy implementation of auto-instrumentation of the following annotations:
#412