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

Metric overhaul #1504

Merged
merged 28 commits into from
Nov 15, 2023
Merged

Metric overhaul #1504

merged 28 commits into from
Nov 15, 2023

Conversation

rorbech
Copy link
Contributor

@rorbech rorbech commented Sep 6, 2023

This PR reworks analytics collection to track individual platform builds and aligns submitted data with other SDKs.

This also introduces introduces the ability to print the collected information to the Gradle log (with warning loglevel) by setting the enviroment variable

REALM_PRINT_ANALYTICS=true

There is strictly no need to run this as a service anymore as we don't really gather metrics across tasks anymore. But felt more appropriate to keep it around if we should extent the responsibilities at some point.

TODOs

  • Model and API feature tracking - Will be done in a separate PR

Closes #127
Closes #1390
Closes #1492

@rorbech rorbech marked this pull request as ready for review September 8, 2023 13:57
Copy link
Collaborator

@nhachicha nhachicha left a comment

Choose a reason for hiding this comment

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

LGTM 👍 minor stuff!

// Task to fetch core version from dependency.list from core submodule
tasks.create("coreVersion", Exec::class.java) {
workingDir = project.file(listOf("..", "external", "core").joinToString(File.separator))
commandLine = listOf("grep", "^VERSION", "dependencies.list")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if grep is available on Windows? It would probably be safer to use the Kotlin API to read the file content and find it that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Damn it. You and your windows machine 😅

Copy link
Contributor Author

@rorbech rorbech Sep 19, 2023

Choose a reason for hiding this comment

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

I updated it to read the file through Kotlin API on top of Gradles file content provider API so now it should be fully platform agnostic and appropriately regenerate if external/core/dependencies.list is updated.

@rorbech
Copy link
Contributor Author

rorbech commented Sep 22, 2023

Analytics is now printed if the print option is enabled (with REALM_PRINT_ANALYTICS=true), and submitted to the endpoint unless disabled (with REALM_DISABLED_ANALYTICS=true).

The analytics information is only gathered if neither needed for printing nor submission.

This enable us to test collection in CI enviroments by enable printing but keeping it disabled.

Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

Looking really good. Mostly minor comments and then we should probably also retest this on Windows 😅

dependencies {
classpath("io.realm.kotlin:gradle-plugin:${Realm.version}")
}
extra["realmVersion"] = file("${rootProject.rootDir.absolutePath}/../../../buildSrc/src/main/kotlin/Config.kt")
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is because you want to decouple the tests completely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It we use buildSrc to gain access to Config.kt it is problematic to use Kotlin and AGP versions that are different from the ones in Config.kt because buildSrc applies a number of plugins and that will fix the versions.

@@ -106,8 +115,10 @@ tasks.create("pluginVersion") {
// Generated file. Do not edit!
package io.realm.kotlin.gradle
internal const val PLUGIN_VERSION = "${project.version}"
internal const val CORE_VERSION = "${coreVersion}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we often point to commits that are not tagged releases, this might not be 100% accurate. But I assume that appending the submodule commit sha might be a bit tricky, so maybe this fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not tricky ... on the client side. But it will probably clutter the remote view. I guess we should rather just strive to use tagged core-releases 😉 For discussion see https://mongodb.slack.com/archives/C04M17MCY0H/p1693920525143069

@rorbech
Copy link
Contributor Author

rorbech commented Oct 30, 2023

This just requires manual verification on Windows - @cmelchior let me know when tested.

Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

Testing this on Windows with Java 17, I got the following failure on the Gradle 6 integration test:

-----------
* What went wrong:
Execution failed for task ':single-platform:compileReleaseJavaWithJavac'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x6592fe6e) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x6592fe6e

Using

gw :single-platform:assemble --configuration-cache

The Gradle 8 test worked fine using the same command.

@rorbech
Copy link
Contributor Author

rorbech commented Nov 13, 2023

Testing this on Windows with Java 17, I got the following failure on the Gradle 6 integration test:

-----------
* What went wrong:
Execution failed for task ':single-platform:compileReleaseJavaWithJavac'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x6592fe6e) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x6592fe6e

Using

gw :single-platform:assemble --configuration-cache

The Gradle 8 test worked fine using the same command.

I don't expect this to be an issue with PR nor our plugin. I can provoke something similar on a Mac:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @251de3f8

from our current main's example/min-android-sample and try to build it with Java 17. I also get the same error if
I strip applying our plugin and dependencies.

Does it work assembling the min-android-sample from main on Windows with Java 17?

@cmelchior
Copy link
Contributor

After testing, you are correct, this is also happening on main, so is unrelated to this PR.

Copy link
Contributor

@cmelchior cmelchior left a comment

Choose a reason for hiding this comment

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

:shipit:

@rorbech rorbech merged commit 140dc21 into main Nov 15, 2023
2 checks passed
@rorbech rorbech deleted the cr/metrics-overhaul branch November 15, 2023 12:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants