1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00

feat: using histogram metrics

This commit is contained in:
kwasniew 2025-09-24 16:56:04 +02:00
parent 145def0f25
commit 78255edb96
No known key found for this signature in database
GPG Key ID: 43A7CBC24C119560
2 changed files with 6 additions and 0 deletions

View File

@ -75,6 +75,7 @@ export class BatchHistogram {
reset(): void { reset(): void {
this.store.clear(); this.store.clear();
this.bucketBoundaries.clear();
} }
get() { get() {

View File

@ -59,6 +59,10 @@ export class MetricsTranslator {
): boolean { ): boolean {
const existingBoundaries = existingHistogram.bucketBoundaries; const existingBoundaries = existingHistogram.bucketBoundaries;
if (existingBoundaries.size !== newBuckets.length) {
return true;
}
for (const bucket of newBuckets) { for (const bucket of newBuckets) {
if (!existingBoundaries.has(bucket.le)) { if (!existingBoundaries.has(bucket.le)) {
return true; return true;
@ -184,6 +188,7 @@ export class MetricsTranslator {
if (existingMetric && existingMetric instanceof BatchHistogram) { if (existingMetric && existingMetric instanceof BatchHistogram) {
const firstSample = metric.samples[0]; // all samples should have same buckets const firstSample = metric.samples[0]; // all samples should have same buckets
const needsRecreation = const needsRecreation =
!firstSample?.buckets ||
this.hasNewLabels(existingMetric, labelNames) || this.hasNewLabels(existingMetric, labelNames) ||
this.hasNewBuckets(existingMetric, firstSample.buckets); this.hasNewBuckets(existingMetric, firstSample.buckets);