Skip to content

Commit fd26ad1

Browse files
committed
feat: Add diagnostics library for tracking stats/counters
Add a generic library that can be used to track counters, or elapsed time (e.g. how long it takes on average to connect to mqtt). This is a copy of https://github.com/allenporter/python-google-nest-sdm/blob/main/google_nest_sdm/diagnostics.py This is an initial pass to add a few initial example metrics for MQTT, but we can add more as we need fine grained details in diagnostics.
1 parent f5a0bb4 commit fd26ad1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

roborock/mqtt/roborock_session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ async def _mqtt_client(self, params: MqttParams) -> aiomqtt.Client:
240240
async with self._client_lock:
241241
self._client = client
242242
for topic in self._client_subscribed_topics:
243+
self._diagnostics.increment("resubscribe")
243244
_LOGGER.debug("Re-establishing subscription to topic %s", topic)
244245
# TODO: If this fails it will break the whole connection. Make
245246
# this retry again in the background with backoff.
@@ -321,6 +322,7 @@ def delayed_unsub():
321322
unsub() # Remove the callback from CallbackMap
322323
# If no more callbacks for this topic, start idle timer
323324
if not self._listeners.get_callbacks(topic):
325+
self._diagnostics.increment("unsubscribe_idle_start")
324326
schedule_unsubscribe()
325327
else:
326328
_LOGGER.debug("Unsubscribing topic %s, still have active callbacks", topic)

0 commit comments

Comments
 (0)