insights-api-common 4.0.2 → 4.0.3
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/insights/api/common/metrics.rb +19 -1
- data/lib/insights/api/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 972f294824d5a600f98ee785b45a310d83b2b056d1bc9e8fee4af2afd1d43f9c
|
|
4
|
+
data.tar.gz: 93f294e0f183debaa844c4ff4272c4fa921a8aef51269d0caffbe8a630a84de7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f12eb12ddd1bd97b486d88e09463c5ac29f95350ad5431c1ff292df6eb222700628d9a8e0cc055ec7942a0e5a8814aad7249edfd4603f691d6426d85faceef1
|
|
7
|
+
data.tar.gz: df4bbc507ad58eb38b94e8bddebd3dd3060a3f4eff33d807b85a88cfd5d9fa33ade8239db2dbae7197b56548fec1fbf456a953fa57226be2b9da1b709f04c0ca
|
|
@@ -2,13 +2,14 @@ module Insights
|
|
|
2
2
|
module API
|
|
3
3
|
module Common
|
|
4
4
|
class Metrics
|
|
5
|
-
def self.activate(config, prefix)
|
|
5
|
+
def self.activate(config, prefix, args = {})
|
|
6
6
|
require 'prometheus_exporter'
|
|
7
7
|
require 'prometheus_exporter/client'
|
|
8
8
|
|
|
9
9
|
ensure_exporter_server
|
|
10
10
|
enable_in_process_metrics
|
|
11
11
|
enable_web_server_metrics(prefix)
|
|
12
|
+
setup_custom_metrics(args[:custom_metrics])
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
private_class_method def self.ensure_exporter_server
|
|
@@ -33,6 +34,23 @@ module Insights
|
|
|
33
34
|
require "insights/api/common/middleware/web_server_metrics"
|
|
34
35
|
Rails.application.middleware.unshift(Insights::API::Common::Middleware::WebServerMetrics, :metrics_prefix => prefix)
|
|
35
36
|
end
|
|
37
|
+
|
|
38
|
+
private_class_method def self.setup_custom_metrics(custom_metrics)
|
|
39
|
+
return if custom_metrics.nil?
|
|
40
|
+
|
|
41
|
+
custom_metrics.each do |metric|
|
|
42
|
+
instance_variable_set("@#{metric[:name]}_#{metric[:type]}", PrometheusExporter::Client.default.register(metric[:type], metric[:name], metric[:description]))
|
|
43
|
+
|
|
44
|
+
define_singleton_method(metric[:name]) do
|
|
45
|
+
case metric[:type]
|
|
46
|
+
when :counter
|
|
47
|
+
instance_variable_get("@#{metric[:name]}_#{metric[:type]}")&.observe(1)
|
|
48
|
+
else
|
|
49
|
+
"Metric of type #{metric[:type]} unsupported, implement it in Insights::API::Common::Metrics#L45"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
36
54
|
end
|
|
37
55
|
end
|
|
38
56
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: insights-api-common
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Insights Authors
|
|
@@ -413,7 +413,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
413
413
|
- !ruby/object:Gem::Version
|
|
414
414
|
version: '0'
|
|
415
415
|
requirements: []
|
|
416
|
-
rubygems_version: 3.0.
|
|
416
|
+
rubygems_version: 3.0.3
|
|
417
417
|
signing_key:
|
|
418
418
|
specification_version: 4
|
|
419
419
|
summary: Common Utilites for Insights microservices
|