Skip to content

Commit 6726816

Browse files
authored
fix: include the metric and label names in deprecation warning (#114)
1 parent 8a8bb1c commit 6726816

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ const metricTypes = {
2121
SUMMARY: "summary",
2222
};
2323

24-
function deprecateMetaForLabels() {
24+
function deprecateMetaForLabels(metric, label) {
2525
if (!deprecateMetaForLabels.warned) {
2626
deprecateMetaForLabels.warned = true;
2727
process.emitWarning(
28-
`
28+
`Got label ${label} for metric ${metric} using the meta property.
29+
2930
Using metric meta property for labels (eg. metric({ meta: { label: "value" } })) is now deprecated and will be removed in a future version.
30-
Please use the "labels" key instead.
31-
See https://github.com/metrics-js/client for up to date usage.
32-
`,
31+
Please use the labels key instead (eg metric({ labels: { label: "value" } })).
32+
33+
See https://github.com/metrics-js/client for up to date usage.`,
3334
"DeprecationWarning",
3435
);
3536
}
@@ -90,7 +91,7 @@ module.exports = class PrometheusMetricsConsumer extends Writable {
9091
if (key === "buckets") return;
9192
if (key === "quantiles") return;
9293

93-
deprecateMetaForLabels();
94+
deprecateMetaForLabels(metric.name, key);
9495

9596
labelNames.push(key);
9697
labelValues.push(metric.meta[key]);

0 commit comments

Comments
 (0)