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: Collect usage metrics on license renewal (no-changelog) #7486

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

csuermann
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2023

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Make sure to check off this list before asking for review.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Oct 21, 2023
@codecov
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (774fe20) 33.56% compared to head (e750bca) 33.55%.

❗ Current head e750bca differs from pull request most recent head 8f93a15. Consider uploading reports for the commit 8f93a15 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7486      +/-   ##
==========================================
- Coverage   33.56%   33.55%   -0.02%     
==========================================
  Files        3399     3398       -1     
  Lines      207458   207603     +145     
  Branches    22425    22429       +4     
==========================================
+ Hits        69632    69652      +20     
- Misses     136698   136829     +131     
+ Partials     1128     1122       -6     
Files Coverage Δ
packages/cli/src/License.ts 45.92% <33.33%> (-0.17%) ⬇️

... and 57 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@csuermann csuermann requested a review from ivov October 21, 2023 12:13
ivov
ivov previously approved these changes Oct 23, 2023
Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

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

LGTM. Only minor comments.

packages/cli/src/License.ts Outdated Show resolved Hide resolved
packages/cli/src/License.ts Show resolved Hide resolved
packages/cli/test/unit/License.test.ts Show resolved Hide resolved
{
name: 'activeWorkflows',
value: await Container.get(WorkflowRepository).count({ where: { active: true } }),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Products can be configured to support the collection of usage metrics from consumers. product.metrics is an array of {name: string, type: 'counter' | 'gauge'} objects

Why the difference between value and type? Are the docs outdated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

product.metrics refers to the metric definitions maintained in License Server, whereas the SDK's collectUsageMetrics() callback expects an array of name / value pairs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Not very familiar with the setup.

@cypress
Copy link

cypress bot commented Oct 23, 2023

Passing run #2553 ↗︎

0 258 0 0 Flakiness 0

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 csuermann 🗃️ e2e/*
Project: n8n Commit: 8f93a1503c
Status: Passed Duration: 09:14 💡
Started: Oct 23, 2023 5:24 PM Ended: Oct 23, 2023 5:33 PM

Review all test suite changes for PR #7486 ↗︎

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

ivov
ivov previously approved these changes Oct 23, 2023
@github-actions
Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

ivov
ivov previously approved these changes Oct 23, 2023
@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@@ -65,6 +69,7 @@ export class License {
loadCertStr: async () => this.loadCertStr(),
saveCertStr,
deviceFingerprint: () => this.instanceSettings.instanceId,
collectUsageMetrics,
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this isn't going to be called frequently enough to try to optimize the DB calls made here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

collectUsageMetrics() is only called prior license renewal, which happens once every 10 days by default. It is also triggered when n8n starts up and when the usage and plan page is opened, but probably not often enough to optimize DB calls 😄

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@csuermann csuermann merged commit 3ef771e into master Oct 23, 2023
57 checks passed
@csuermann csuermann deleted the collect-usage-metrics-2 branch October 23, 2023 19:39
MiloradFilipovic added a commit that referenced this pull request Oct 25, 2023
* master: (30 commits)
  🚀 Release 1.14.0 (#7514)
  ci: Fix oclif manifest generation
  feat(Switch Node): Add support for infinite Switch outputs (#7499)
  🚀 Release 1.13.0 (#7512)
  fix(core): Ensure nodes post-processors run in the correct order (#7500)
  feat(editor): Add PH tracking to event (#7511)
  fix(core): Fix workflow activation with history and workflow history for EE (no-changelog) (#7508)
  refactor(core): Make executions pruning more resilient (#7480)
  fix(Spreadsheet File Node): Fix include empty cells not working with v2 (#7505)
  fix(core): Create instance settings directory recursively (no-changelog) (#7506)
  fix(Microsoft SQL Node): Prevent SQL injection (#7467)
  refactor(core): Make pruning via lifecycle configuration in S3 mode mandatory (#7482)
  fix(core): Always derive `instanceId` from the encryption key (no-changlog) (#7501)
  fix(MQTT Trigger Node): Fix node causing a start up hang when active (#7498)
  feat: Collect usage metrics on license renewal (no-changelog) (#7486)
  fix(core): Fix `frontend.settings` external hook execution (#7496)
  fix(Redis Node): Fix adding sets data types (#7444)
  fix: Save new version of the workflow instead of the previous (no-changelog) (#7428)
  refactor(core): Abstract away InstanceSettings and `encryptionKey` into injectable services (no-changelog) (#7471)
  fix(Customer.io Node): Fix api endpoint when using EU region (#7485)
  ...
@janober
Copy link
Member

janober commented Oct 25, 2023

Got released with n8n@1.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants