Skip to content

Counter metric is reset when it has no labels #255

@alex-wearisma

Description

@alex-wearisma

Hello,

I implemented a custom MongoDB metric data store. While testing it, I noticed that counters with no labels are reset every time I relaunch my application. This does not happen to labeled counters.

After inspecting the code, it looks like this line resets the counters:

init_label_set({}) if labels.empty?

From top of my head I can't think of a scenario when this behaviour would be useful for counters or other metric types. Also, based on the tests, store should handle nil cases and initialise values to 0.0 before incrementing:

metric_store.increment(labels: { foo: "zzz" }, by: 3)

Would it be safe to remove it?

Thank you,
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions