Skip to content

counter/histogram with enabledExemplars=true, the labels() function does not bind the input parameters properly #777

Description

@jdmarshall
				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.

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions