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(app-gen, worker): Add MetricsService #4928

Merged
merged 12 commits into from
Dec 2, 2023
Merged

Conversation

rifont
Copy link
Collaborator

@rifont rifont commented Dec 2, 2023

What change does this PR introduce?

  • Add MetricsService to provide generic capability to send metrics to Cloud service monitoring tools
  • Update existing New Relic metrics use in Worker to consume MetricService

Why was this change needed?

By providing a capability to send metrics to any cloud monitoring tools, we can support self-hosted customers to use metrics tools of their choice and standardize metrics gathering on the Novu platform. Additionally, application-level metrics can be used as auto-scaling indicators.

Other information (Screenshots)

Startup logs info
image

Queue Metrics on Cloudwatch (verified locally with AWS Creds)
image

Queue Metrics on NewRelic (verified locally with NR Creds)
image

@rifont rifont changed the title Create metrics service feat(app-gen, worker): Add MetricsService Dec 2, 2023
@rifont rifont requested review from Cliftonz and scopsy December 2, 2023 04:03
webSocketsQueueService = moduleRef.get<WebSocketsQueueService>(WebSocketsQueueService);
workflowQueueService = moduleRef.get<WorkflowQueueService>(WorkflowQueueService);
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This wasn't being used, it's overridden below.

nr.recordMetric(`Queue/${deploymentName}/${queueService.topic}/delayed`, delayedCount);
nr.recordMetric(`Queue/${deploymentName}/${queueService.topic}/active`, activeCount);

Logger.verbose(`Queue/${deploymentName}/${queueService.topic}`, { waitCount, delayedCount, activeCount });
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Verbose logging is handled in the metrics service now.

"@types/sinon": "^9.0.0",
"codecov": "^3.5.0",
"cpx": "^1.5.0",
"dotenv": "^8.2.0",
"chai": "^4.2.0",
"jest": "^27.1.0",
"newrelic": "^9",
"npm-run-all": "^4.1.5",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding newrelic as devDependecies to keep the peer deps working as normal.

Copy link
Contributor

@scopsy scopsy left a comment

Choose a reason for hiding this comment

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

Amazing work!

Comment on lines +152 to +163
describe('Azure', () => {
it('should contain AzureMetricsService if METRICS_SERVICE is set to AZURE', async () => {
process.env.METRICS_SERVICE = 'AZURE';
const metricsServices = await createServices();

expect(
metricsServices.some(
(metricsService) => metricsService instanceof AzureMetricsService
)
).toBe(true);
delete process.env.METRICS_SERVICE;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing for the future!

@scopsy scopsy merged commit 94da0d4 into next Dec 2, 2023
@scopsy scopsy deleted the create-metrics-service branch December 2, 2023 09:12
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.

2 participants