gruf-prometheus 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faf2407a0d57a111725037bef23e55ca38ec318ef0307f06f729042dcaab9561
4
- data.tar.gz: 561ee316f087f56e485d1ea3debd3c34df3764100babfce3576cfc8e64a19a3a
3
+ metadata.gz: df1faaee21e1065478281be50074bd940e032f504dec8d6a96c6782924333351
4
+ data.tar.gz: '08156327334040cfbcc2edde0f54ad8b99a9832922facdee4edf7ec8940d821e'
5
5
  SHA512:
6
- metadata.gz: 4425dcd1a8861c7f6fefbf27b4cbebe782a9ef246b5819e469944c2ff032a1aef75eac4bd75d0ff5b8b7bfa3de09ad7a7a5062f34d207b713cfe07573b1b3c63
7
- data.tar.gz: 18e6cf9983f630798fb73f564fcd50a2f6b3a3852ffe07e93d755f4f73775880373fd82e17f282a487c80877a35f33477b5cf6397754fd16f630ff3bebbed829
6
+ metadata.gz: d5b9b609394f12d2f2380088bd61c1fcba5ae6fcc6ff638c9d8f059deec9994e1f8776b8adf642604a74c03a71312a76959cbf3bbb2f0814f9403a1d3dd80b41
7
+ data.tar.gz: e502778428e5e923180a8de75d252d7e9a470c38fe37fff65e26a9d9e183910de4209271a6ec2de2e441b892c52e70a1912a413d042872efd7fe768f62580732
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ Changelog for the gruf-prometheus gem.
2
2
 
3
3
  ### Pending Release
4
4
 
5
+ ### 1.2.0
6
+
7
+ - Add the ability to have custom collectors and type collectors
8
+
5
9
  ### 1.1.0
6
10
 
7
11
  - Refactor collector/type collector to utilize new base abstractions
data/README.md CHANGED
@@ -33,6 +33,8 @@ You can further configure via bc-prometheus-ruby with:
33
33
  | process_label | The label to use for metric prefixing | grpc |
34
34
  | process_name | Label to use for process name in logging | grpc |
35
35
  | collection_frequency | The period in seconds in which to collect metrics | 30 |
36
+ | collectors | Any collectors you would like to start with the server. Passed as a hash of collector class => options | {} |
37
+ | type_collectors | Any type collectors you would like to start with the server. Passed as an array of collector objects | [] |
36
38
 
37
39
  ## License
38
40
 
@@ -21,10 +21,6 @@ module Gruf
21
21
  # Prometheus instrumentor for gRPC servers
22
22
  #
23
23
  class Collector < Bigcommerce::Prometheus::Collectors::Base
24
- def type
25
- 'grpc'
26
- end
27
-
28
24
  def collect(metrics = {})
29
25
  metrics[:type] = 'grpc'
30
26
  rpc_server = grpc_server
@@ -24,7 +24,9 @@ module Gruf
24
24
  VALID_CONFIG_KEYS = {
25
25
  process_label: 'grpc',
26
26
  process_name: 'grpc',
27
- collection_frequency: 30
27
+ collection_frequency: 30,
28
+ type_collectors: [],
29
+ collectors: []
28
30
  }.freeze
29
31
 
30
32
  attr_accessor *VALID_CONFIG_KEYS.keys
@@ -30,6 +30,9 @@ module Gruf
30
30
  logger.info "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Starting #{server.class}"
31
31
  prometheus_server.add_type_collector(::Gruf::Prometheus::TypeCollector.new)
32
32
  prometheus_server.add_type_collector(::PrometheusExporter::Server::ActiveRecordCollector.new)
33
+ custom_type_collectors.each do |tc|
34
+ prometheus_server.add_type_collector(tc)
35
+ end
33
36
  prometheus_server.start
34
37
  sleep 2 unless ENV['RACK_ENV'] == 'test' # wait for server to come online
35
38
  start_collectors(server: server)
@@ -62,9 +65,13 @@ module Gruf
62
65
  options: {
63
66
  server: server
64
67
  },
68
+ type: 'grpc',
65
69
  client: ::Bigcommerce::Prometheus.client,
66
70
  frequency: ::Gruf::Prometheus.collection_frequency
67
71
  )
72
+ custom_collectors.each do |collector, arguments|
73
+ collector.start(arguments)
74
+ end
68
75
  end
69
76
 
70
77
  ##
@@ -87,6 +94,20 @@ module Gruf
87
94
  logger: logger
88
95
  )
89
96
  end
97
+
98
+ ##
99
+ # @return [Array<Bigcommerce::Prometheus::TypeCollectors::Base>]
100
+ #
101
+ def custom_type_collectors
102
+ @options.fetch(:type_collectors, [])
103
+ end
104
+
105
+ ##
106
+ # @return [Array<Bigcommerce::Prometheus::Collectors::Base>]
107
+ #
108
+ def custom_collectors
109
+ @options.fetch(:collectors, [])
110
+ end
90
111
  end
91
112
  end
92
113
  end
@@ -17,6 +17,6 @@
17
17
  #
18
18
  module Gruf
19
19
  module Prometheus
20
- VERSION = '1.1.0'
20
+ VERSION = '1.2.0'
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruf-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-18 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake