Workload counter resets

The Machine-Readable Status documentation lists a set of workload performance stats.

    "workload": {
      // A given counter can be reset.
...
      "bytes": {
        "written": {"counter": 0, "hz": 0.0, "roughness": 0.0}
      },
...

I’d like to use these counters for metrics in my application, but I’m very unclear on what the comment indicates. Are counters reset automatically, as part of the normal operations of FoundationDB? If so, when? Or is there some endpoint that resets these counters manually?

Thanks!

I think the intent of the comment is to say that there are various circumstances (e.g. a process being restarted) which could result in a given counter being reset, so you shouldn’t rely on it never decreasing. There doesn’t exist any direct way for you to reset counters, although depending on the counter you could in theory cause it to be reset by triggering the behavior that would reset it (e.g. by intentionally restarting the appropriate process(es)).

The actual circumstances that could cause a counter to reset probably depend on which counter is involved, but I think the main idea is that these are stored in data structures in memory that aren’t persistent. In addition to being reset by a process being restarted as mentioned above, I think some counters might reset in response to a database recovery (i.e. re-recruiting the transaction subsystem) as this causes certain parts of the cluster to move to new locations. For some of the counters, it’s conceivable that they could be reset for other reasons, too, though none come to mind off the top of my head.

Thanks, that’s very helpful!