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

Class Method Summary collapse

Class Method Details

.marshal(registry) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/prometheus/client/formats/text.rb', line 17

def marshal(registry)
  metrics = registry.metrics.map do |metric|
    samples = metric.values.flat_map do |label_set, value|
      representation(metric, label_set, value)
    end

    [metric.name, { type: metric.type, help: metric.docstring, samples: samples }]
  end

  Helper::MetricsRepresentation.to_text(metrics)
end

.marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/prometheus/client/formats/text.rb', line 29

def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir)
  file_list = Dir.glob(File.join(path, '*.db')).sort
    .map {|f| Helper::PlainFile.new(f) }
    .map {|f| [f.filepath, f.multiprocess_mode.to_sym, f.type.to_sym, f.pid] }

    FastMmapedFileRs.to_metrics(file_list.to_a)
end