Last active
March 29, 2021 13:29
-
-
Save alastair/c410c8bd987e4e726a5f6b9e8b88fd5f to your computer and use it in GitHub Desktop.
redis storage for counters
This file contains 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
register a new counter: | |
metrics.init('listenbrainz', 'listenbrainz-spotify-reader', 'lemmy') | |
first argument is for grouping all LB containers | |
second argument comes from CONTAINER_NAME | |
third argument comes from hostname | |
Mappings, stored in redis when .init() is called: | |
service-to-container set for 'listenbrainz': (listenbrainz-spotify-reader, listenbrainz-web, listenbrainz-cron) | |
mapping of container to hostname: {listenbrainz-spotify-reader: lemmy, listenbrainz-web: paco} | |
counters - normal interaction with counters: | |
redis hash: listenbrainz-spotify-reader: num_users=10, num_listens=3000 | |
redis hash: mbid_matching: artists=20, recordings=30 | |
endpoint: | |
This happens on the web container, so we can't generate any data on demand | |
(e.g. we don't know the hostname that listenbrainz-spotify-reader is running on at this point, we need it to be stored earlier) | |
"get me all counters for service 'listenbrainz'" | |
- looks in service-to-container set => (listenbrainz-spotify-reader, listenbrainz-web, listenbrainz-cron) | |
- for each container: | |
- get hostname from container-to-hostname map | |
- get counts | |
- build results dict | |
- return list of all container dicts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment