Module: Prometheus::Client::Formats::JSON
- Defined in:
- lib/prometheus/client/formats/json.rb
Overview
JSON format is a deprecated, human-readable format to expose the state of a given registry.
Constant Summary collapse
- MEDIA_TYPE =
'application/json'
- SCHEMA =
'prometheus/telemetry'
- VERSION =
'0.0.2'
- CONTENT_TYPE =
%(#{MEDIA_TYPE}; schema="#{SCHEMA}"; version=#{VERSION})
- MAPPING =
{ summary: :histogram }
Class Method Summary collapse
Class Method Details
.marshal(registry) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/prometheus/client/formats/json.rb', line 18 def self.marshal(registry) registry.metrics.map do |metric| { baseLabels: metric.base_labels.merge(__name__: metric.name), docstring: metric.docstring, metric: { type: MAPPING[metric.type] || metric.type, value: metric.values.map { |l, v| { labels: l, value: v } }, }, } end.to_json end |