-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
183 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...ns-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/RuntimeInformationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Contains all runtime information relevant for observability. | ||
*/ | ||
|
||
package com.mongodb.jbplugin.observability | ||
|
||
import com.intellij.openapi.application.ApplicationInfo | ||
import com.intellij.openapi.application.PermanentInstallationID | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.util.SystemInfo | ||
|
||
/** | ||
* Represents all the gathered information from the host machine. | ||
* | ||
* @property userId | ||
* @property osName | ||
* @property arch | ||
* @property jvmVendor | ||
* @property jvmVersion | ||
* @property buildVersion | ||
* @property applicationName | ||
*/ | ||
data class RuntimeInformation( | ||
val userId: String, | ||
val osName: String, | ||
val arch: String, | ||
val jvmVendor: String, | ||
val jvmVersion: String, | ||
val buildVersion: String, | ||
val applicationName: String, | ||
) | ||
|
||
/** | ||
* Computes, if possible, the current runtime information. It provides a method that | ||
* returns a RuntimeInformation object. | ||
* | ||
* Do not use RuntimeInformation for feature toggling. | ||
* | ||
* @see RuntimeInformation | ||
*/ | ||
@Service | ||
class RuntimeInformationService { | ||
private val userId = getOrDefault("<userId>") { PermanentInstallationID.get() } | ||
private val osName = getOrDefault("<osName>") { SystemInfo.getOsNameAndVersion() } | ||
private val arch = getOrDefault("<arch>") { SystemInfo.OS_ARCH } | ||
private val jvmVendor = getOrDefault("<jvmVendor>") { SystemInfo.JAVA_VENDOR } | ||
private val jvmVersion = getOrDefault("<jvmVersion>") { SystemInfo.JAVA_VERSION } | ||
private val buildVersion = getOrDefault("<fullVersion>") { ApplicationInfo.getInstance().fullVersion } | ||
private val applicationName = getOrDefault("<fullApplicationName>") { | ||
ApplicationInfo.getInstance().fullApplicationName | ||
} | ||
|
||
fun get(): RuntimeInformation = RuntimeInformation( | ||
userId, | ||
osName, | ||
arch, | ||
jvmVendor, | ||
jvmVersion, | ||
buildVersion, | ||
applicationName | ||
) | ||
|
||
private fun <T> getOrDefault(default: T, supplier: () -> T): T { | ||
return try { | ||
supplier() | ||
} catch (ex: Throwable) { | ||
return default | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
...s/jetbrains-plugin/src/main/kotlin/com/mongodb/jbplugin/observability/TelemetryService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.