-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More http_server_request_duration_seconds buckets
Add more buckets to http_server_request_duration_seconds. 10 seconds is unfortunately not long enough. The weirdness with the Prometheus::Middleware::Collector initializing the registry is avoided by creating a subclass that assumes a the registry is already populated, and fetches the metrics object from it. The exceptions were exporting malformed metrics. Rather than redefining the #trace method, the RegisteredCollector defaults to an object that shares enough of the same interface as a metric to fool #trace and #record. Because the FakeMetric is not part of the registry, the exporter does not attempt to export them.
- Loading branch information
Showing
3 changed files
with
49 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Prometheus | ||
module Middleware | ||
class RegisteredCollector < Collector | ||
protected | ||
|
||
def init_request_metrics | ||
requests_name = :"#{@metrics_prefix}_requests_total" | ||
durations_name = :"#{@metrics_prefix}_request_duration_seconds" | ||
@requests = @registry.get(requests_name) || FakeMetrics | ||
@durations = @registry.get(durations_name) || FakeMetrics | ||
end | ||
|
||
def init_exception_metrics | ||
exceptions_name = :"#{@metrics_prefix}_exceptions_total" | ||
@exceptions = @registry.get(exceptions_name) || FakeMetrics | ||
end | ||
|
||
class FakeMetrics | ||
def self.increment(*) | ||
end | ||
|
||
def self.observe(*) | ||
end | ||
end | ||
end | ||
end | ||
end |