This repository has been archived by the owner on Nov 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update prometheus-client. Use my fork with the :most_recent aggregation.
- Loading branch information
1 parent
d72480c
commit 936d4d6
Showing
5 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
# The app is currently run with multiple processes, which means that the /metrics endpoint is not consistent.. That's fine for now, at least with this one metric. | ||
# frozen_string_literal: true | ||
|
||
# Use DirectFileStore if we run multiple processes | ||
store_settings = {} | ||
if ENV["WEB_CONCURRENCY"] | ||
require "prometheus/client/data_stores/direct_file_store" | ||
app_path = File.expand_path("../../..", __FILE__) | ||
Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFileStore.new(dir: "#{app_path}/tmp/prometheus/") | ||
store_settings[:aggregation] = :most_recent | ||
|
||
# Clean up old metric files | ||
Dir["#{app_path}/tmp/prometheus/*.bin"].each do |file_path| | ||
File.unlink(file_path) | ||
end | ||
end | ||
|
||
prometheus = Prometheus::Client.registry | ||
|
||
$metrics = { | ||
ratelimit_remaining: prometheus.gauge(:ratelimit_remaining, "Remaining GitHub ratelimit."), | ||
ratelimit_remaining: prometheus.gauge(:ratelimit_remaining, store_settings: store_settings, docstring: "Remaining GitHub ratelimit."), | ||
} |
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