Skip to content

Conversation

@deffrian
Copy link
Collaborator

Ref: A-414

All counters that are reported with attributes are not set to zero

@deffrian deffrian changed the title feature: default counter value feat: default counter value Jan 26, 2026
Copy link
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea but it needs a different way of initializing counters to 0

Comment on lines 24 to 29
defaultValue: number | undefined = 0,
): UpDownCounter {
const counter = meter.createUpDownCounter(metric);
if (defaultValue !== undefined) {
counter.add(defaultValue);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this way of passing a default will work. JS can't differentiate between a missing parameter and an explicit undefined

> function test(a = "foo") { console.log(a) }
> test()
foo
> test(undefined)
foo
> test(0)
0

@deffrian deffrian force-pushed the nikita/default-counter branch from 56c636f to f17d7f2 Compare January 27, 2026 19:08
attributes

more attributes
@deffrian deffrian force-pushed the nikita/default-counter branch from f17d7f2 to 72d0fbe Compare January 27, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants