nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
177 stars 20 forks source link

set KV watcher ephemeral consumer name #190

Closed MauriceVanVeen closed 1 year ago

MauriceVanVeen commented 1 year ago

Overview

A KV watcher uses an ephemeral consumer with a random name, to make it (optionally) more recognisable in the CLI and/or graphs in Grafana, allow for setting/overwriting the KV watcher name.

The behavior is documented in ADR-8.

aricart commented 1 year ago

@MauriceVanVeen this is a good suggestion

ripienaar commented 1 year ago

Do you have suggestions of what the names might be? How would you realistically tell 100 watchers apart in a meaningful way where the names are still random enough to avoid clashes?

MauriceVanVeen commented 1 year ago

@ripienaar, would say the random names could stay as-is (so no need to change the default), and adding the ability to explicitly set a name yourself if desired. Like the way you would manually name a durable consumer, but then setting such a name on the ephemeral consumer used by the watcher.

For example, then it would support the case where specific applications are using one/multiple watchers for a longer period of time. A recognisable name would help to identify the watchers, especially when using streams with durable consumers with explicit names combined with same/other apps also relying on KV watchers for state.

ripienaar commented 1 year ago

Would require some careful thinking for sure, how to detect clashes in consumer names cos that will big time mess up watcher functionality for example.

MauriceVanVeen commented 1 year ago

Yeah, either checking for clashes or using a custom name as a suffix Something like EGRF38JR_application_name_here.

ripienaar commented 1 year ago

Using description fields would be safer of course - but I understand its not quite as handy.

derekcollison commented 1 year ago

I have some thoughts on watchers and they may change (under the covers, not API or functionality wise) such that this is not as much an issue.

jnmoyne commented 1 year ago

From a monitoring point of view it would be cool if you can tell not just the application name that created the watcher but also what it's watching on.

Jarema commented 1 year ago

We can now leverage metadata to do that.