-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
chore: handle aggregation queries sequentially follow up #8450
chore: handle aggregation queries sequentially follow up #8450
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
src/lib/metrics-gauge.ts
Outdated
count: number; | ||
labels: RestrictedRecord<GaugeDefinition<R>['labelNames']>; | ||
}; | ||
type MapResult<R> = (result: R) => MetricValue<R> | MetricValue<R>[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single task can output different counts for different labels. This is useful for cases like client_apps_total
at line 40
src/lib/metrics.ts
Outdated
// schedule and execute immediately | ||
await dbMetrics.registerGaugeDbMetric({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tasks need to execute immediately because the tests expect that. I'd argue that some of these can be delayed, but maybe they are important because of other components depending on these. So I'm delaying this decision until we migrated all gauges to dbMetrics
try { | ||
dbMetrics.refreshDbMetrics(); | ||
|
||
const stats = await instanceStatsService.getStats(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getStats was triggering many queries in parallel, some of which were not used in prometheus.
@@ -512,16 +858,6 @@ export default class MetricsMonitor { | |||
legacyTokensActive.reset(); | |||
legacyTokensActive.set(deprecatedTokens.activeLegacyTokens); | |||
|
|||
if (maxEnvironmentStrategies) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got migrated to: https://github.com/Unleash/unleash/pull/8450/files#diff-0610ce1595d1dcf150ca2efb2f0c5806d082f5bc6b8429a437970c7d60171cbdR181-R194 where both the gauge definition and refresh query are together
eventBus.on( | ||
events.STAGE_ENTERED, | ||
(entered: { stage: string; feature: string }) => { | ||
if (flagResolver.isEnabled('trackLifecycleMetrics')) { | ||
logger.info( | ||
`STAGE_ENTERED listened ${JSON.stringify(entered)}`, | ||
); | ||
} | ||
featureLifecycleStageEnteredCounter.increment({ | ||
stage: entered.stage, | ||
}); | ||
}, | ||
); | ||
|
||
eventBus.on( | ||
events.EXCEEDS_LIMIT, | ||
({ | ||
resource, | ||
limit, | ||
}: { resource: string; limit: number }) => { | ||
exceedsLimitErrorCounter.increment({ resource, limit }); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved up to line 485 on the right side. Now lives inside registerPrometheusMetrics
instead of startMonitoring
const { collectStaticCounters, collectDbMetrics } = | ||
registerPrometheusMetrics( | ||
config, | ||
stores, | ||
version, | ||
eventBus, | ||
instanceStatsService, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start monitoring now calls helper functions that register prometheus metrics and then adds schedules to frequently update these metrics
@@ -338,11 +369,12 @@ export class InstanceStatsService { | |||
this.clientInstanceStore.getDistinctApplicationsCount(30), | |||
this.clientInstanceStore.getDistinctApplicationsCount(), | |||
]); | |||
return { | |||
this.appCount = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store the result, so it can be used internally (line 261)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed 1on1, LGTM
7a4c855
into
proposal/handle-aggregation-queries-sequentially
This is a follow up on #8446