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(core): Add metric for active workflow count #13420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juusotn8n
Copy link
Contributor

@juusotn8n juusotn8n commented Feb 21, 2025

Summary

Adds a new metric for active workflow count. This metric is checked every time metrics are collected. Due to the workflow count being potentially quite high, we also cache the result and utilize the cached value.

This metric needs to be enabled separately and the TTL can be configured.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/CP-1797/add-metric-for-active-workflow-count

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@juusotn8n juusotn8n changed the title feat(core): add metric for active workflow count feat(core): Add metric for active workflow count Feb 21, 2025
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Feb 21, 2025
@juusotn8n juusotn8n force-pushed the cp-1797-add-metric-for-active-workflow-count branch 2 times, most recently from 18c1702 to 583e8c9 Compare February 21, 2025 15:02
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Adds a new metric for active workflow count. This metric is checked
every time metrics are collected. Due to the workflow count being
potentially quite high, we also cache the result and utilize the
cached value.

This metric needs to be enabled separately and the TTL can be
configured.
@juusotn8n juusotn8n force-pushed the cp-1797-add-metric-for-active-workflow-count branch from 583e8c9 to 71559c1 Compare February 24, 2025 10:27
Comment on lines +60 to +64
async getActiveCount() {
return await this.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.

Curious why not get this from memory instead? See ActiveWorkflows.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware this was kept up to date somewhere in memory. I can try it out, would make the implementation simpler.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants