-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Synapse Stats Exporter #140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, left some minor comments, interested to see the tests on this.
def _on_start(self, _: ops.HookEvent) -> None: | ||
"""Handle start event.""" | ||
if self.get_admin_access_token(): | ||
self._start_synapse_stats_exporter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn'g mjolnir require an access token as well? Should it be added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Mjolnir requires it too.
- If Mjolnir is enabled, the charm will instantiate a Mjolnir class passing state as parameter
- The class observes the collect status event that will check for the requirements and enable Mjolnir when everything is set
get_admin_access_token = getattr(self._charm, "get_admin_access_token", None) | ||
if not get_admin_access_token: | ||
access_token = self._charm_state.synapse_config.admin_access_token | ||
if not access_token: | ||
logging.error("Failed to get method get_admin_access_token.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That error can be reworked now due to the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now if the admin access token is None, the charm will be put on MaintenanceStatus. Do you think it should be changed?
self._charm.unit.status = ops.MaintenanceStatus(
"Failed to get admin access token. Please, check the logs."
)
5beb98b
to
b13def7
Compare
Test coverage for 53d1097
Static code analysis report
|
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mariyan Dimitrov <[email protected]>
* Change Mjolnir web address to fix abuse reports * Try to deploy Prometheus and Grafana from edge --------- Co-authored-by: Mariyan Dimitrov <[email protected]> Co-authored-by: arturo-seijas <[email protected]>
Co-authored-by: arturo-seijas <[email protected]>
* Create backup action * Remove unused import * Add missing src-docs * Reorder functions * Improve comment with suggestion to limit bandwidth * Add mark.s2 * Fix src-docs * Remeve unused backup_id parameter * Improving func comment * Replace string addition with f-string * Add comment in pathlib * Unneeded lines * Remove code to protect against int casting as that should not happen * Remove default expected_size as it is not used * Use full path for bash command * Improve formatting and set bash to full path * Get the media directory dinamically from the homeserver.yaml * Add missing how-to --------- Co-authored-by: Amanda H. L. de Andrade Katz <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Christopher Bartz <[email protected]>
* Create list backups action * Improve comments. Sent data in event.fail * Allow more than 1000 objects in list-backups * Remove unused fields in S3Backup * Improve test comments * Fix typo * Improve comments in docstrings * Rename function from iterate_objects to list_s3_objects * Apply suggestions from code review use list instead of typing.List Co-authored-by: Christopher Bartz <[email protected]> * Remove unused import and change typing.List to list --------- Co-authored-by: Christopher Bartz <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: arturo-seijas <[email protected]> Co-authored-by: Mariyan Dimitrov <[email protected]> Co-authored-by: javierdelapuente <[email protected]> Co-authored-by: Amanda H. L. de Andrade Katz <[email protected]>
* Add cron service and cleanup script * Fix rockfile * Fix restart_synapse() * Remove unused fn * Fix restart_synapse() * Fix linting * Fix rockfile * Throttle cleanup operations * Add missing headers * Add some licensing exceptions * Try to fix headers ignore once again * Make scripts added to the rock executable * Rerun CI * Only modify rockcraft.yml where necessary * Fix rockcraft scripts permissions * Fix typo --------- Co-authored-by: Amanda H. L. de Andrade Katz <[email protected]> Co-authored-by: arturo-seijas <[email protected]>
82bb8b2
I'm closing this PR in favor of splitting the changes into smaller ones. This is already too messy. |
Overview
In order to collect and monitor the number of users and rooms in the Synapse instance, this PR install the synapse-stats-exporter so the metrics can be extracted by Prometheus.
Also, it refactors how the charm handle the admin_access_token.
Before the refactor, the admin access token was handled only by the charm and used by Mjolnir.
But since the Stats Exporter needs it too, it was complex to let this in the charm instead of letting the Synapse module handle it.
So what happens now?
start event is emitted meaning that (hopefully) the workload was started (not just the container)
If the admin access token already exists (as a secret or as peer data), start the Stats Exporter and return
If the admin access token doesn't exist, create it via create_admin_user and save it in the charm_state
Mjolnir and Stats Exporter will get the admin_access_token via charm_state
Also, Mjolnir will create the user using the create_user available in the synapse module instead of calling actions.register_user (that didn't make much sense)
This is how the modules depend on each other now:
Rationale
Collect Synapse statistics.
Juju Events Changes
N/A
Module Changes
Pebble module has a new layer.
Library Changes
N/A
Checklist
src-docs
urgent
,trivial
,complex
)Documentation should be updated after the exporter being available.