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

feat: add POC for measuring adoption #859

Merged
merged 102 commits into from
Mar 26, 2024

Conversation

smoya
Copy link
Member

@smoya smoya commented Oct 23, 2023

Description

Important

Not ready yet, just marking as ready for review to let CI run tests

This PR is meant as a simple POC for demonstrating how we could collect metrics for measuring adoption.
This code uses the following shared library https://github.com/smoya/asyncapi-adoption-metrics. It can be shared between CLI, Studio, and any other tool that wants to keep track of those metrics.

In this example, we are just measuring the happy path of validate CLI command. The sink (aka backend where metrics are sent) in this POC is just logging to StdOut (console.log).
The output when validating a simple and small doc atm will output the collected metrics, I.e.:

asyncapi-adoption.action.executed       COUNTER [
  _asyncapi_version: '2.6.0',
  _asyncapi_servers: 1,
  _asyncapi_channels: 1,
  _asyncapi_messages: 1,
  _asyncapi_operations_send: 1,
  _asyncapi_operations_receive: 0,
  _asyncapi_schemas: 1,
  success: true,
  validation_result: 'valid',
  action: 'validate'
]       1

Of course, a lot of things are missing surrounding this, like the important warning to the user saying we are collecting metrics, a way to disable, etc etc etc.
Also, we might want to encapsulate this logic as well in a single file or something we can reuse for other commands in CLI

cc @Amzani @peter-rr @fmvilas @derberg

Related issue(s)
#841

src/commands/validate.ts Outdated Show resolved Hide resolved
@smoya
Copy link
Member Author

smoya commented Oct 23, 2023

Something we might want to move on is to use Oclif hooks for lifecycle events so we can create the metric metadata on the prerun hook, and send the metric with a success: true in the postrun hook or rather with a success: false a the catch part.

In that way we would be always sending a metric, no matters if the command fails or not, and log the cmd result (OK|KO).

@peter-rr
Copy link
Member

@smoya Let me work on the metrics recording implementation for all the actions/commands as you did for validate.ts

@peter-rr peter-rr force-pushed the feat/adoptionMetrics branch from 6e667b5 to 5b25de2 Compare November 6, 2023 12:03
@smoya smoya force-pushed the feat/adoptionMetrics branch from c9027b5 to e9e79f6 Compare November 22, 2023 21:36
smoya and others added 6 commits November 23, 2023 11:03
* feat: add POC for measuring adoption

* Update convert command

* Add metrics recording to some commands

* Add new metric recording for action invocation

* Add new metric recording for another command

* Reduce metrics recording code

---------

Co-authored-by: Sergio Moya <1083296+smoya@users.noreply.github.com>
@smoya smoya force-pushed the feat/adoptionMetrics branch from 4fabc9c to 3ce1520 Compare November 23, 2023 22:48
smoya and others added 4 commits November 24, 2023 00:57
…#5)

* Add new method to unify logic so metrics are collected when any command is invoked

* Remove some unnecessary code

* Change NR license key

* Fix 'init()' to return a proper value for the command invoked

* Unify logic for the remaining commands

* Unify logic also for 'action.executed' metric

* Rollback last changes
@smoya smoya marked this pull request as ready for review December 12, 2023 13:00
@smoya
Copy link
Member Author

smoya commented Dec 12, 2023

Important

Not ready yet, just marking as ready for review to let CI run tests

@Amzani
Copy link
Collaborator

Amzani commented Mar 19, 2024

@peter-rr anything blocking this PR from merging ?, we would like to get some adoption insights :)

@peter-rr
Copy link
Member

@peter-rr anything blocking this PR from merging ?, we would like to get some adoption insights :)

Now I just need to update the dependency with asyncapi-adoption-metrics repo and also resolve the current conflicts. I'll let you know in case I find any blocker.

@peter-rr
Copy link
Member

@Amzani
Conflicts already solved 👍 Just waiting for approval to be merged.

@peter-rr
Copy link
Member

peter-rr commented Mar 19, 2024

Yo folks @derberg @Souvikns @magicmatatjahu ,
Could you have a look at this PR for a final review?

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@Souvikns Souvikns left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

@peter-rr
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit be50880 into asyncapi:master Mar 26, 2024
11 checks passed
@derberg
Copy link
Member

derberg commented Mar 26, 2024

@Souvikns please have a look into CI. Since this PR was merged, the release pipeline fails

Next PRs like -> #1297 also are not releasable for now

https://github.com/asyncapi/cli/actions/workflows/if-nodejs-release.yml

@Souvikns
Copy link
Member

Having some issues while installing dependencies, I tried installing the dependencies locally and it works fine, I have no idea what is happening in the GitHub action. Looks like some cache error.

npm ERR! code EEXIST
npm ERR! syscall open
npm ERR! path C:\npm\cache\_cacache\tmp\f46cd6fa
npm ERR! errno -4075
npm ERR! EEXIST: file already exists, open 'C:\npm\cache\_cacache\tmp\f46cd6fa'
npm ERR! File exists: C:\npm\cache\_cacache\tmp\f46cd6fa
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

@Amzani
Copy link
Collaborator

Amzani commented Mar 26, 2024

@Souvikns isn't it something related to this
https://github.com/asyncapi/cli/actions/caches
Screenshot 2024-03-26 at 21 47 57

@Souvikns
Copy link
Member

Looks like cleaning the cache by force, could potentially solve this, but in gh action we have to update the workflow file to add a new step to clean cache. @derberg can we make changes to the workflow file for this action run? What options do we have here?

@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants