Module: PgEventstore::Web::Metrics::Helpers
- Defined in:
- lib/pg_eventstore/web/metrics/helpers.rb,
sig/pg_eventstore/web/metrics/helpers.rbs
Overview
Route helpers of Application.
Instance Method Summary collapse
- #metrics_response(collector_classes) ⇒ String
-
#requested_sets ⇒ Array<String>
Subscription sets a scrape asks for.
Instance Method Details
#metrics_response(collector_classes) ⇒ String
10 11 12 13 14 15 |
# File 'lib/pg_eventstore/web/metrics/helpers.rb', line 10 def metrics_response(collector_classes) connection = metrics_connection families = collector_classes.flat_map { _1.new(connection, sets: requested_sets).call } content_type(Formatter::CONTENT_TYPE) Formatter.new.call(families) end |
#requested_sets ⇒ Array<String>
Subscription sets a scrape asks for. Accepts a repeated param ("?set=A&set=B" - what Prometheus emits for
params: {set: [A, B]}) or a comma separated list ("?set=A,B"). Empty means every set.
The query string is parsed directly because Sinatra's params keeps only the last value of a repeated key
unless it is written as "set", which Prometheus does not do.
23 24 25 26 |
# File 'lib/pg_eventstore/web/metrics/helpers.rb', line 23 def requested_sets query = Rack::Utils.parse_query(request.query_string) Array(query['set'] || query['set[]']).flat_map { _1.to_s.split(',') }.map(&:strip).reject(&:empty?) end |