Skip to content

Commit

Permalink
Current metrics moved inside of health metrics function
Browse files Browse the repository at this point in the history
Current metrics is only needed within this function to compare
the lengths between current metrics and health metrics. Instead
of grabbging current metrics outside of the function it is now
grabbing the current metrics data before the length check.
  • Loading branch information
mdtagg committed May 11, 2024
1 parent adcc071 commit 88a527d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions chronos_npm_package/controllers/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@ mongo.communications = ({ microservice, slack, email }) => {
mongo.health = async ({ microservice, interval, mode }) => {
//MetricsModel tracks which metrics are selected in the MetricsContainer component
//HealthModel tracks all the cpu health data in each of the services databases
const getCurrentMets = async () => await MetricsModel.find({ mode });
const currentMetrics = async () => await getCurrentMets()
currentMetrics()

setInterval(() => {
collectHealthData()
.then(async healthMetrics => {
const currentMetrics = await MetricsModel.find({mode})

if (currentMetrics.length !== healthMetrics.length) {
await mongo.addMetrics(healthMetrics, mode, currentMetrics);
Expand Down

0 comments on commit 88a527d

Please sign in to comment.