Skip to content

Commit 1efb0bd

Browse files
committed
float not supported in platform
1 parent ec551ca commit 1efb0bd

File tree

2 files changed

+15
-3
lines changed
  • runtimes/js/encore.dev/metrics
  • tsparser/src/legacymeta

2 files changed

+15
-3
lines changed

runtimes/js/encore.dev/metrics/mod.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

tsparser/src/legacymeta/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ fn basic_to_proto(basic: &crate::parser::types::Basic) -> i32 {
832832
(match basic {
833833
Basic::Boolean => Builtin::Bool,
834834
Basic::String => Builtin::String,
835-
Basic::Number => Builtin::Float64,
835+
Basic::Number => Builtin::Int64,
836836
_ => Builtin::Any,
837837
}) as i32
838838
}

0 commit comments

Comments
 (0)