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

Add metrics plugin to track device download keys task #7438

Merged
merged 8 commits into from
Nov 2, 2022

Conversation

amitkma
Copy link
Contributor

@amitkma amitkma commented Oct 24, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • A plugin based approach is implemented so that clients using metrics sdk can integrate tracking of events/tasks.
  • A new plugin MetricsPlugin is added which is implemented by VectorMetricsPlugin.
  • Sentry tracking can track how many times the keys are being downloaded from server.

Motivation and context

  • In order to improve the crypto layer, we need to have some metrics to track and improve. download_device_keys is one of such metrics.

Tests

  • Enable analytics in Element-Android app.
  • Try to open some conversations (rooms), especially the ones for which you don't have keys yet.
  • You must see the count of download_device_keys increasing here.

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 11 and 12

Checklist

@amitkma amitkma marked this pull request as ready for review October 27, 2022 13:08
@amitkma amitkma requested review from a team and mnaturel and removed request for a team October 31, 2022 09:07
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Just a few comments

*/
@OptIn(ExperimentalContracts::class)
inline fun <T> measureMetric(metricMeasurementPlugins: List<MetricPlugin>, block: () -> T): T {
contract {
Copy link
Member

Choose a reason for hiding this comment

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

what's contract? Do we really need it (i can see it's experimental)

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 basically a way to tell the compiler about how the function behaves. Sometimes the compiler doesn't know or is not fully aware of certain conditions or returns. So you can specify an effect when a function is invoked to help the compiler.
In our case, it allows us to write this code:

val response: KeysQueryResponse 

measureMetric(plugin) {
    response = block() // this won't be possible without contracts.
}

@sonarcloud
Copy link

sonarcloud bot commented Oct 31, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

52.4% 52.4% Coverage
0.0% 0.0% Duplication

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

LGTM

@amitkma amitkma merged commit b674665 into develop Nov 2, 2022
@amitkma amitkma deleted the feature/amitkma/sentry-tracking branch November 2, 2022 08:13
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.

3 participants