const counterInstance = new Counter({
name: 'counter_exemplar_label_test',
help: 'help',
labelNames: ['method', 'code'],
enableExemplars: true,
});
const labels = counterInstance.labels({ method: 'get', code: '200' });
labels.inc({}); // 1
labels.inc({
exemplarLabels: { traceId: 'trace_id_test', spanId: 'span_id_test' },
});
There's a performance issue here since labels() should be able to validate the label values and then not repeat them. Likely what needs to happen is the two paths need to be unwound or converted into a set of file scoped functions that result in the correct output, sort of like how observe() does. That would both address the issue here and provide an incentive to use the labels() function to reduce overhead per call.
This code is exactly duplicated into Histogram and has the exact same bug.
There's a performance issue here since
labels()should be able to validate the label values and then not repeat them. Likely what needs to happen is the two paths need to be unwound or converted into a set of file scoped functions that result in the correct output, sort of like howobserve()does. That would both address the issue here and provide an incentive to use thelabels()function to reduce overhead per call.This code is exactly duplicated into Histogram and has the exact same bug.