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

Instrumentation API part 4 #439

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

LikeTheSalad
Copy link
Contributor

These changes are focused on the "slowrendering" module migration.

@LikeTheSalad LikeTheSalad requested a review from a team June 17, 2024 09:59
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 was renamed to SlowRenderingInstrumentation and then added the installOn method from SlowRenderingDetector.

Copy link
Contributor

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM. Nothing blocking, just a couple of suggestions

}

@Override
public void install(
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can add a @RequiresApi or @ChecksSdkIntAtLeast annotation here or to the class itself to flag attempted usage in a lower API level?1020.

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 didn't think of it because this method (at least for now) is meant to be called by the agent and not directly by our users, although I guess it's not impossible that someone would want to call it directly, so I guess it's probably better to make sure. I'll add the changes.

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've made the changes.

import org.robolectric.annotation.Config
import java.time.Duration

@RunWith(RobolectricTestRunner::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use AndroidJUnit4 test runner here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I was rushing this test earlier today and couldn't make AS find AndroidJUnit4, so I guess there's some missing dependency in this project, though I have some time now so let me take a look at what's missing.

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've made the changes, also made the missing test dependency available to all android lib modules.

* @param interval The period that should be used for polling.
* @return {@code this}
*/
public SlowRenderingInstrumentation setSlowRenderingDetectionPollInterval(Duration interval) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably the agent detects when this class is on the classpath, instantiates it, and installs it. How would we expect this method to ever get called? I think there are no usages outside of tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of now, people will need to know what the instrumentation impl class is to configure a particular instrumentation by using AndroidInstrumentationRegistry, so I guess each instrumentation's README should mention the class name when explaining its configurable params. So for this case, they'd have to write the following to call this method:

AndroidInstrumentationRegistry.get().get(SlowRenderingInstrumentation::class.java).setSlowRenderingDetectionPollInterval(Duration.ofSeconds(2))

I guess we can probably build some helper tools around it in the future to make it less verbose, but that's essentially the way to do so now, though any ideas to improve it are welcome!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@breedx-splk I'm a bit worried about not having all the parts ready before the next release, since the agent won't have any auto instrumentation working until all parts are done, so I'll go ahead and merge this PR and we can continue this discussion on the SIG if you'd like as this way of configuring instrumentations is not exclusive to the slowrendering one anyway.

@LikeTheSalad LikeTheSalad merged commit ab20634 into open-telemetry:main Jun 20, 2024
3 checks passed
@LikeTheSalad LikeTheSalad deleted the instrumentation-api-p4 branch June 20, 2024 08:06
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.

4 participants