-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Prometheus client with default metrics and custom metrics f…
…or RabbitMQ message processing (#460)
- Loading branch information
1 parent
489eaa3
commit 1f0ed62
Showing
9 changed files
with
121 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Counter, Histogram } from 'prom-client'; | ||
|
||
// Metrics for rabbitmq message processing | ||
|
||
// This counter tracks the total number of processed messages, with labels for the queue and status (success or failure) | ||
export const processedMessagesCounter = new Counter({ | ||
name: 'rabbitmq_processed_messages_total', | ||
help: 'Total number of processed messages from RabbitMQ', | ||
labelNames: ['queue', 'status'], | ||
}); | ||
|
||
// This histogram tracks the duration of message processing. It helps monitor how long it takes to process each message. | ||
export const processingDurationHistogram = new Histogram({ | ||
name: 'rabbitmq_message_processing_duration_seconds', | ||
help: 'Duration of message processing in seconds', | ||
labelNames: ['queue'], | ||
buckets: [0.1, 0.5, 1, 5, 10, 30, 60], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import express, { Request, Response } from 'express'; | ||
import { collectDefaultMetrics, register } from 'prom-client'; | ||
|
||
collectDefaultMetrics(); | ||
|
||
const router = express.Router(); | ||
|
||
router.get('/metrics', async (req: Request, res: Response) => { | ||
res.set('Content-Type', register.contentType); | ||
res.end(await register.metrics()); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters