@@ -269,6 +269,8 @@ export class CounterGroup<
269269
270270 /**
271271 * Get a counter for the given label values.
272+ *
273+ * Note: Number values in labels are converted to integers using Math.floor().
272274 */
273275 with ( labels : L ) : AtomicCounter | NoOpCounter {
274276 const labelKey = serializeLabels ( labels ) ;
@@ -286,7 +288,11 @@ export class CounterGroup<
286288 // Allocate slot for this label combination
287289 const labelMap : Record < string , string > = { } ;
288290 for ( const [ key , value ] of Object . entries ( labels ) ) {
289- labelMap [ key ] = String ( value ) ;
291+ if ( typeof value === "number" ) {
292+ labelMap [ key ] = String ( Math . floor ( value ) ) ;
293+ } else {
294+ labelMap [ key ] = String ( value ) ;
295+ }
290296 }
291297
292298 const labelPairs = Object . entries ( labelMap ) ;
@@ -408,6 +414,8 @@ export class GaugeGroup<L extends Record<keyof L, string | number | boolean>> {
408414
409415 /**
410416 * Get a gauge for the given label values.
417+ *
418+ * Note: Number values in labels are converted to integers using Math.floor().
411419 */
412420 with ( labels : L ) : AtomicGauge | NoOpGauge {
413421 const labelKey = serializeLabels ( labels ) ;
@@ -425,7 +433,11 @@ export class GaugeGroup<L extends Record<keyof L, string | number | boolean>> {
425433 // Allocate slot for this label combination
426434 const labelMap : Record < string , string > = { } ;
427435 for ( const [ key , value ] of Object . entries ( labels ) ) {
428- labelMap [ key ] = String ( value ) ;
436+ if ( typeof value === "number" ) {
437+ labelMap [ key ] = String ( Math . floor ( value ) ) ;
438+ } else {
439+ labelMap [ key ] = String ( value ) ;
440+ }
429441 }
430442
431443 const labelPairs = Object . entries ( labelMap ) ;
0 commit comments