pushgateway-metrics 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/configuration.rb +7 -0
- data/lib/pushgateway_metrics.rb +10 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d8307594c410fe8cbae1a4deee0e46d0c1bb44a5deb7631328cfbf894d65f5
|
4
|
+
data.tar.gz: f4b7d5ebdae24d01753796722cf1808107590f3bb7e89a21c1e5c169be86cef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61e8eb6b84800fbcc373c6c44390612663771fac08354f90776e9525c1e80674cdcbb0aa366982b9bc52f3e8971408d11ebebad533930776242689d7f941c686
|
7
|
+
data.tar.gz: '0893be5c3969ee19b535de8ef0a6b36c0b4ec9f2c73ebe49a1e5e067cf3ebb676d0d9902299a483bfa831968716154cfe071a4d71182521dddcb582540cbb537'
|
data/lib/configuration.rb
CHANGED
@@ -16,6 +16,13 @@ module PushgatewayMetrics
|
|
16
16
|
attr_accessor :job
|
17
17
|
attr_accessor :instance_name
|
18
18
|
attr_accessor :gateway
|
19
|
+
attr_writer :logger
|
20
|
+
|
21
|
+
def logger
|
22
|
+
@logger ||= Logger.new($stdout).tap do |log|
|
23
|
+
log.progname = self.name
|
24
|
+
end
|
25
|
+
end
|
19
26
|
|
20
27
|
def initialize
|
21
28
|
@job = 'local'
|
data/lib/pushgateway_metrics.rb
CHANGED
@@ -8,18 +8,21 @@ require 'active_support/core_ext/string/inflections'
|
|
8
8
|
|
9
9
|
# Ruby interface to a Prometheus pushgateway
|
10
10
|
module PushgatewayMetrics
|
11
|
-
|
12
11
|
# Definitions for creating and pushing metrics
|
13
12
|
class Metrics
|
14
13
|
def self.instance
|
15
14
|
@instance ||= new
|
16
15
|
end
|
17
16
|
|
17
|
+
def conf
|
18
|
+
PushgatewayMetrics.configuration
|
19
|
+
end
|
20
|
+
|
18
21
|
def gateway
|
19
22
|
@gateway ||= Prometheus::Client::Push.new(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
conf.job,
|
24
|
+
conf.instance_name,
|
25
|
+
conf.gateway
|
23
26
|
)
|
24
27
|
end
|
25
28
|
|
@@ -29,7 +32,7 @@ module PushgatewayMetrics
|
|
29
32
|
|
30
33
|
def error(message)
|
31
34
|
errored true
|
32
|
-
|
35
|
+
conf.logger.info message
|
33
36
|
end
|
34
37
|
|
35
38
|
def registry
|
@@ -40,11 +43,11 @@ module PushgatewayMetrics
|
|
40
43
|
push_to_gateway unless errored
|
41
44
|
rescue Errno::ECONNREFUSED
|
42
45
|
unless errored
|
43
|
-
error "Connection to
|
46
|
+
error "Connection to gateway on #{conf.gateway} refused. Is it up?"
|
44
47
|
end
|
45
48
|
rescue Net::OpenTimeout
|
46
49
|
unless errored
|
47
|
-
error "Connection to
|
50
|
+
error "Connection to gateway on #{conf.gateway} timed out. Is it up?"
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|