Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Log errors related to gathering stats and updating metrics instead of exiting the process #13

Merged
merged 7 commits into from
Jan 3, 2024

Conversation

busma13
Copy link
Contributor

@busma13 busma13 commented Jan 3, 2024

Updates the teraslice-exporter to catch, log, and count errors when calling terasliceStats.update() and updateTerasliceMetrcis() instead of exiting. Any http request that does not return a 200 status code is considered an error, so network issues will cause the exporter to exit.

Additional output added to /metrics endpoint:

# HELP teraslice_exporter_errors Number of errors encountered by teraslice exporter.
# TYPE teraslice_exporter_errors gauge
teraslice_exporter_errors{error_type="update_stats_errors"} 0
teraslice_exporter_errors{error_type="update_metrics_errors"} 0

Example of logged errors:

{"name":"teraslice_exporter","terasliceUrl":"http://localhost:5678/","hostname":"Peters-MacBook-Pro.local","pid":56281,"level":50,"msg":"Error encountered getting terasliceStats: Error: Error getting http://localhost:5678/v1/cluster/state: HTTPError: Response code 500 (Internal Server Error)","time":"2024-01-02T22:36:08.957Z","v":0}
{"name":"teraslice_exporter","terasliceUrl":"http://localhost:5678/","hostname":"Peters-MacBook-Pro.local","pid":56281,"level":50,"msg":"Error encountered getting terasliceStats: Error: Error getting http://localhost:5678/v1/cluster/controllers: HTTPError: Response code 500 (Internal Server Error)","time":"2024-01-02T22:36:19.031Z","v":0}

Fixes: #12

@busma13 busma13 changed the title Log errors instead of exiting Log errors related to gathering stats and updating metrics instead of exiting the process Jan 3, 2024
@busma13 busma13 requested a review from godber January 3, 2024 20:49
@godber godber merged commit 411c203 into main Jan 3, 2024
@godber godber deleted the log-errors-instead-of-exiting branch January 3, 2024 23:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capture error responses as a metric and log rather than crash
2 participants