-
Notifications
You must be signed in to change notification settings - Fork 44
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
Instrumentation API part 4 #439
Conversation
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.
This was renamed to SlowRenderingInstrumentation
and then added the installOn
method from SlowRenderingDetector
.
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.
LGTM. Nothing blocking, just a couple of suggestions
} | ||
|
||
@Override | ||
public void install( |
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.
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.
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 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.
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've made the changes.
import org.robolectric.annotation.Config | ||
import java.time.Duration | ||
|
||
@RunWith(RobolectricTestRunner::class) |
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.
Can use AndroidJUnit4
test runner here too
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.
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.
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'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) { |
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.
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.
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.
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!
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.
@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.
These changes are focused on the "slowrendering" module migration.