Repository navigation
Metrics: count the Wear OS app as a watch, and Home Assistant as its own family - #379
Merged
Merged
Conversation
…own family The Wear OS app identifies itself on its User-Agent, as `Sheaf Android Wear/<version>`, and sends no X-Sheaf-Client header. The family parser only ever read the header, so every watch request landed in `other`, the watch family read zero, and the sessions list called the watch "Unknown". An official app prefix on the User-Agent is now honoured when no header is sent: it is the same claim carried in a different header. A browser string never matches an official prefix, so the web app is still counted only from its own header, as before. The stored session name and the extended tier's version parse read the same effective claim. An API-key request whose User-Agent starts `HomeAssistant/` is now the `homeassistant` family rather than plain `api`. Named automation families are decided from a fixed table, so the label set stays bounded, and each gets its own active-account sketch under the api kind, a subset of the api total rather than a split of it. `api` itself keeps meaning "an API key, whatever it was".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #337.
Sheaf Android Wear/<version>on its User-Agent and nothing onX-Sheaf-Client, and the family parser only read the header, so watch traffic wasotherand the sessions list named those sessions "Unknown".effective_client_headernow returns the header when sent, else the User-Agent when it starts with an official app prefix, else nothing; the family parser, the stored session name and the extended tier's version parse all read it. The no-browser-fallback rule forwebis unchanged: a browser string never matches an official prefix.sheaf android wear/is added to the prefix table (it is not a prefix collision withsheaf android/; they diverge after "android").client_family_fromtakes the User-Agent as well; for an API-key credential it checks a fixed table of integration prefixes (homeassistant/, what the shared HTTP session sends) and otherwise staysapi. A session or JWT with that User-Agent is stillother.homeassistantis added toClientFamilyand the metric label literal, so the pre-warm loop, the per-family gauges and the overlap pairs pick it up; it gets its own sketch under the api kind, flushed and restored like the interactive ones, soactive_accounts_*_by_client{client_family="homeassistant"}is a subset of{auth_kind="api"}rather than a split of it. Other integrations can be added to the same table as they are identified.Verification
watchwith and without an empty header and is outranked by a sent header; a browser string and okhttp stayother; Home Assistant User-Agents arehomeassistantonly under an API key; the version parse works from the effective claim; the stored session name for a header-less watch is its User-Agent and classifies aswatch.