DEV: add frozen_string_literal
This helps avoid uneeded string allocations Also: - Add rubocop to travis - Bump version
This commit is contained in:
parent
e3c7820eb1
commit
5d6d777635
1
.travis
1
.travis
|
@ -7,3 +7,4 @@ rvm:
|
||||||
- 2.5
|
- 2.5
|
||||||
- 2.6
|
- 2.6
|
||||||
- jruby
|
- jruby
|
||||||
|
script: bach -c "bundle exec rubocop && bundle exec rake"
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
0.4.11 - 15-05-2019
|
||||||
|
|
||||||
|
- Fix: Handle stopping nil worker_threads in Client
|
||||||
|
- Dev: add frozen string literals
|
||||||
|
|
||||||
0.4.10 - 29-04-2019
|
0.4.10 - 29-04-2019
|
||||||
|
|
||||||
- Fix: Custom label support for puma collector
|
- Fix: Custom label support for puma collector
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
guard :minitest do
|
guard :minitest do
|
||||||
# with Minitest::Unit
|
# with Minitest::Unit
|
||||||
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
||||||
|
|
2
Rakefile
2
Rakefile
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "bundler/gem_tasks"
|
require "bundler/gem_tasks"
|
||||||
require "rake/testtask"
|
require "rake/testtask"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative '../lib/prometheus_exporter'
|
require_relative '../lib/prometheus_exporter'
|
||||||
require_relative '../lib/prometheus_exporter/client'
|
require_relative '../lib/prometheus_exporter/client'
|
||||||
require_relative '../lib/prometheus_exporter/server'
|
require_relative '../lib/prometheus_exporter/server'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MyCustomCollector < PrometheusExporter::Server::Collector
|
class MyCustomCollector < PrometheusExporter::Server::Collector
|
||||||
def initialize
|
def initialize
|
||||||
@gauge1 = PrometheusExporter::Metric::Gauge.new("thing1", "I am thing 1")
|
@gauge1 = PrometheusExporter::Metric::Gauge.new("thing1", "I am thing 1")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "prometheus_exporter/version"
|
require_relative "prometheus_exporter/version"
|
||||||
require "json"
|
require "json"
|
||||||
require "thread"
|
require "thread"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "instrumentation/process"
|
require_relative "instrumentation/process"
|
||||||
require_relative "instrumentation/method_profiler"
|
require_relative "instrumentation/method_profiler"
|
||||||
require_relative "instrumentation/sidekiq"
|
require_relative "instrumentation/sidekiq"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Instrumentation
|
module PrometheusExporter::Instrumentation
|
||||||
class DelayedJob
|
class DelayedJob
|
||||||
JOB_CLASS_REGEXP = %r{job_class: (\w+:{0,2})+}.freeze
|
JOB_CLASS_REGEXP = %r{job_class: (\w+:{0,2})+}.freeze
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# see https://samsaffron.com/archive/2017/10/18/fastest-way-to-profile-a-method-in-ruby
|
# see https://samsaffron.com/archive/2017/10/18/fastest-way-to-profile-a-method-in-ruby
|
||||||
module PrometheusExporter::Instrumentation; end
|
module PrometheusExporter::Instrumentation; end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
require 'json'
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "json"
|
||||||
|
|
||||||
# collects stats from puma
|
# collects stats from puma
|
||||||
module PrometheusExporter::Instrumentation
|
module PrometheusExporter::Instrumentation
|
||||||
|
@ -30,7 +32,7 @@ module PrometheusExporter::Instrumentation
|
||||||
def collect_puma_stats(metric)
|
def collect_puma_stats(metric)
|
||||||
stats = JSON.parse(::Puma.stats)
|
stats = JSON.parse(::Puma.stats)
|
||||||
|
|
||||||
if stats.key? 'workers'
|
if stats.key?("workers")
|
||||||
metric[:phase] = stats["phase"]
|
metric[:phase] = stats["phase"]
|
||||||
metric[:workers_total] = stats["workers"]
|
metric[:workers_total] = stats["workers"]
|
||||||
metric[:booted_workers_total] = stats["booted_workers"]
|
metric[:booted_workers_total] = stats["booted_workers"]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'raindrops'
|
require 'raindrops'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "metric/base"
|
require_relative "metric/base"
|
||||||
require_relative "metric/counter"
|
require_relative "metric/counter"
|
||||||
require_relative "metric/gauge"
|
require_relative "metric/gauge"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "metric"
|
require_relative "metric"
|
||||||
require_relative "server/type_collector"
|
require_relative "server/type_collector"
|
||||||
require_relative "server/web_collector"
|
require_relative "server/web_collector"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
|
|
||||||
# minimal interface to implement a customer collector
|
# minimal interface to implement a customer collector
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class DelayedJobCollector < TypeCollector
|
class DelayedJobCollector < TypeCollector
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class HutchCollector < TypeCollector
|
class HutchCollector < TypeCollector
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class PumaCollector < TypeCollector
|
class PumaCollector < TypeCollector
|
||||||
PUMA_GAUGES = {
|
PUMA_GAUGES = {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'prometheus_exporter/client'
|
require 'prometheus_exporter/client'
|
||||||
require_relative '../instrumentation/unicorn'
|
require_relative '../instrumentation/unicorn'
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class RunnerException < StandardError; end;
|
class RunnerException < StandardError; end
|
||||||
class WrongInheritance < RunnerException; end;
|
class WrongInheritance < RunnerException; end
|
||||||
|
|
||||||
class Runner
|
class Runner
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class SidekiqCollector < TypeCollector
|
class SidekiqCollector < TypeCollector
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter::Server
|
module PrometheusExporter::Server
|
||||||
class TypeCollector
|
class TypeCollector
|
||||||
def type
|
def type
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PrometheusExporter
|
module PrometheusExporter
|
||||||
VERSION = "0.4.10"
|
VERSION = "0.4.11"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CustomTypeCollector < PrometheusExporter::Server::TypeCollector
|
class CustomTypeCollector < PrometheusExporter::Server::TypeCollector
|
||||||
def type
|
def type
|
||||||
"custom1"
|
"custom1"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/metric'
|
require 'prometheus_exporter/metric'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/metric'
|
require 'prometheus_exporter/metric'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/metric'
|
require 'prometheus_exporter/metric'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/metric'
|
require 'prometheus_exporter/metric'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/metric'
|
require 'prometheus_exporter/metric'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
require 'rack/test'
|
require 'rack/test'
|
||||||
require 'prometheus_exporter/middleware'
|
require 'prometheus_exporter/middleware'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class PrometheusExporterTest < Minitest::Test
|
class PrometheusExporterTest < Minitest::Test
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'mini_racer'
|
require 'mini_racer'
|
||||||
require 'prometheus_exporter/server'
|
require 'prometheus_exporter/server'
|
||||||
|
@ -283,7 +285,7 @@ class PrometheusCollectorTest < Minitest::Test
|
||||||
|
|
||||||
def test_it_can_collect_puma_metrics
|
def test_it_can_collect_puma_metrics
|
||||||
collector = PrometheusExporter::Server::Collector.new
|
collector = PrometheusExporter::Server::Collector.new
|
||||||
client = PipedClient.new(collector, custom_labels: { service: 'service1' } )
|
client = PipedClient.new(collector, custom_labels: { service: 'service1' })
|
||||||
|
|
||||||
mock_puma = Minitest::Mock.new
|
mock_puma = Minitest::Mock.new
|
||||||
mock_puma.expect(
|
mock_puma.expect(
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/server'
|
require 'prometheus_exporter/server'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'mini_racer'
|
require 'mini_racer'
|
||||||
require 'prometheus_exporter/server'
|
require 'prometheus_exporter/server'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'mini_racer'
|
require 'mini_racer'
|
||||||
require 'prometheus_exporter/server'
|
require 'prometheus_exporter/server'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'prometheus_exporter/server'
|
require 'prometheus_exporter/server'
|
||||||
require 'prometheus_exporter/client'
|
require 'prometheus_exporter/client'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||||
require "prometheus_exporter"
|
require "prometheus_exporter"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue