Module: Prometheus::Client::Formats::Text
- Defined in:
- lib/prometheus/client/formats/text.rb
Overview
Text format is human readable mainly used for manual inspection.
Constant Summary collapse
- MEDIA_TYPE =
'text/plain'.freeze
- VERSION =
'0.0.4'.freeze
- CONTENT_TYPE =
"#{MEDIA_TYPE}; version=#{VERSION}".freeze
- METRIC_LINE =
'%s%s %s'.freeze
- TYPE_LINE =
'# TYPE %s %s'.freeze
- HELP_LINE =
'# HELP %s %s'.freeze
- LABEL =
'%s="%s"'.freeze
- SEPARATOR =
','.freeze
- DELIMITER =
"\n".freeze
- REGEX =
{ doc: /[\n\\]/, label: /[\n\\"]/ }.freeze
- REPLACE =
{ "\n" => '\n', '\\' => '\\\\', '"' => '\"' }.freeze
Class Method Summary collapse
Class Method Details
.marshal(registry) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/prometheus/client/formats/text.rb', line 23 def self.marshal(registry) lines = [] registry.metrics.each do |metric| lines << format(TYPE_LINE, metric.name, metric.type) lines << format(HELP_LINE, metric.name, escape(metric.docstring)) metric.values.each do |label_set, value| representation(metric, label_set, value) { |l| lines << l } end end # there must be a trailing delimiter (lines << nil).join(DELIMITER) end |