question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to reset counter

See original GitHub issue

Hi I have a application that process data on a recurring base (scheduled task). At the start i want to set/export all counter to 0. If a counter has no label, its working fine (the counter gets exported with 0). But I see no way to set a counter to 0, if it has a label. Maybe a Reset() method on the counter could do that:

var counter = metricFactory.CreateCounter("myCounter", "help text", labelNames: new []{ "method", "endpoint"});
counter.WithLabels("GET", "/").Reset();

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mwinklercommented, Sep 10, 2020

@sanych-sun Yes the given sample works for me. I just call .WithLabels() and the counter gets initalized with 0. Thanks.

1reaction
sanych-suncommented, Sep 9, 2020

Hi

If you are using v4 of the library you can just call WithLabels by providing your labels combination on start and it should be reported with 0 value.

var counter = metricFactory.CreateCounter("myCounter", "help text", labelNames: new []{ "method", "endpoint"}); counter.WithLabels("GET", "/");

Or if you want to have unlabelled sample reported - access to the Unlabelled property.

var counter = metricFactory.CreateCounter("myCounter", "help text", labelNames: new []{ "method", "endpoint"}); counter.Unlabelled;

Read more comments on GitHub >

github_iconTop Results From Across the Web

counter-reset
The counter-reset property is used to reset a CSS counter to a given value. It is part of the CSS counter module which...
Read more >
Reset account lockout counter after - Windows Security
The Reset account lockout counter after policy setting determines the number of minutes that must elapse from the time a user fails to...
Read more >
How to reset/set an individual or total counter? - speedohelp
If you want to reset all current counters this is easy. Just invoke the menu, and use reset counters option. But what if...
Read more >
CSS counter-reset property
The counter-reset property creates or resets one or more CSS counters. The counter-reset property is usually used together with the counter-increment ...
Read more >
Resetting a Counter
Click on Reset [Type] Counter. Alternatively, choose File -> Capture Counter -> Reset Counter from the main menu. The selected counter will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found