open-telemetry / opentelemetry-android

OpenTelemetry Tooling for Android
Apache License 2.0
147 stars 33 forks source link

Add basic instrumentation test to start agent on Android #406

Closed bidetofevil closed 4 months ago

bidetofevil commented 4 months ago

This is my proposal for issue #405. It doesn't do much other than start the agent right now, but further verification can be done by adding a fake Exporter to verify that telemetry is logged as expected.

Let me know what y'all think!

bidetofevil commented 4 months ago
  1. How do you run this test from gradle?

Heh, so this isn't running on a real device, but rather just on the JVM using faked Android APIs provided by Robolectric, but it catches most problems associated with running on different versions of Android. The down side is that this is not running on a real device, but the upside is that it works pretty much just as well, and because it doesn't require booting devices up, it'll run really fast too.

  1. Where/when do we think this kind of test should run? On every PR? On merge to main? Nightly? Something else?

This will run as part of the regular unit test suite - if you run ./gradlew test, it'll run

Really curious about how we get this automated!

Once this is merged, it's in automation. And more infra can be built out to test specific components if we can create fakes. We can even simulate network calls by running a mock server on the JVM, though I think for the agent, inspecting what is sent to a fake exporter ought to be sufficient. In time, I can add more tests to demonstrate this.

bidetofevil commented 4 months ago

Ugh, fixed the PR. It's in the right directory now, a separate one but added to the unit test sourceset and will run as part of those