Commit ede29678 authored by Bob Van Landuyt's avatar Bob Van Landuyt 💬
Browse files

Merge branch 'prometheus-client' into 'master'

Adding the Metrics module

See merge request !135

Merged-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Approved-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Reviewed-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Reviewed-by: Hercules Merscher's avatarHercules Merscher <hmerscher@gitlab.com>
Co-authored-by: Hercules Merscher's avatarHercules Merscher <hmerscher@gitlab.com>
parents c51bab6f 61302615
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ LabKit-Ruby provides functionality in a number of areas:
1. `Labkit::Correlation` For accessing the correlation id. (Generated and propagated by `Labkit::Context`)
1. `Labkit::FIPS` for checking for FIPS mode and using FIPS-compliant algorithms.
1. `Labkit::Logging` for sanitizing log messages.
1. `Labkit::Metrics` for metrics. More on the [README](./lib/labkit/metrics/README.md).
1. `Labkit::Tracing` for handling and propagating distributed traces.

## Developing
+9 −0
Original line number Diff line number Diff line
@@ -26,3 +26,12 @@ task :fix => ["rubocop:autocorrect"]
task :verify => %w[spec rubocop]

task :default => %w[verify build]

desc "Start an IRB console with gem pre-loaded"
task :console do
  $LOAD_PATH.unshift(File.expand_path("lib", __dir__))
  require "irb"
  require "gitlab-labkit"
  ARGV.clear
  IRB.start
end
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
  spec.add_runtime_dependency "jaeger-client", "~> 1.1.0"
  spec.add_runtime_dependency "opentracing", "~> 0.4"
  spec.add_runtime_dependency "pg_query", ">= 6.1.0", "< 7.0"
  spec.add_runtime_dependency "prometheus-client-mmap", "~> 1.2.9"
  spec.add_runtime_dependency "redis", "> 3.0.0", "< 6.0.0"

  # Please maintain alphabetical order for dev dependencies
@@ -36,7 +37,9 @@ Gem::Specification.new do |spec|
  spec.add_development_dependency "grpc-tools", ">= 1.62"
  spec.add_development_dependency "httparty", "~> 0.22.0"
  spec.add_development_dependency "httpclient", "~> 2.9.0"
  spec.add_development_dependency "irb", "~> 1.15.2"
  spec.add_development_dependency "pry", "~> 0.12"
  spec.add_development_dependency "pry-byebug", "~> 3.11"
  spec.add_development_dependency "rack", "~> 2.0"
  spec.add_development_dependency "rake", "~> 13.2"
  spec.add_development_dependency "rest-client", "~> 2.1.0"
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ module Labkit
  autoload :FIPS, "labkit/fips"
  autoload :Tracing, "labkit/tracing"
  autoload :Logging, "labkit/logging"
  autoload :Metrics, "labkit/metrics"
  autoload :Middleware, "labkit/middleware"

  # Publishers to publish notifications whenever a HTTP reqeust is made.

lib/labkit/metrics.rb

0 → 100644
+19 −0
Original line number Diff line number Diff line
# frozen_string_literal: true

require "prometheus/client/formats/text"

module Labkit
  # Metrics provides functionality for producing metrics
  module Metrics
    autoload :Client, "labkit/metrics/client"
    autoload :RackExporter, "labkit/metrics/rack_exporter"
    autoload :Null, "labkit/metrics/null"

    class << self
      def prometheus_metrics_text
        dir = Client.configuration.multiprocess_files_dir
        ::Prometheus::Client::Formats::Text.marshal_multiprocess(dir)
      end
    end
  end
end
Loading