topological_inventory-providers-common 2.1.3 → 2.1.4

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: 9848e297a81db270e52355b3caf500b38391f1c35e118ca31cadbec35c3f0c5e
4
- data.tar.gz: ad23c8d4f9a46b6824b20e2d870611d4b3a9c570da00f00a262513934b2349ab
3
+ metadata.gz: 9c17638d4fd82db196de0019069a765bf1c6becdb20498765507ae35a02727eb
4
+ data.tar.gz: a395cd7243591bc3dab9f841e491bb978a2502d2ba1cfec3fdb004de784523dd
5
5
  SHA512:
6
- metadata.gz: b9e92c54114310f529eb78c8faa1ec64fd56350c82086ea2fbe126594afa596757e3a39e6f068929c093b0a607e60cf6ca46f2671dea867a5c87b1f59cae6de7
7
- data.tar.gz: 567e5f95a9138dbc8ac7dd52e26a7fe923075552c89d24c3c4e6111f072c0b1b0fb61c5a1fd463bec86d87f00e359b9ca55cbe728fff5b4a0a2fc7a07e4853ba
6
+ metadata.gz: ba2b33ec9748ef58b4ca7dc30f14d34443c17026e7915fb2bd9aef2a4ec95c4c287a8149a371b91cab88974a0341f7dfd362a987ca55ea644a5b67646adafde6
7
+ data.tar.gz: 41edf911fa71ef7dcdaa220a417a236e8a593a01e227ab4f0f88e70318141f8736ad8bd9bff7e642d6cef1134d017baa8aea0c1c194987b08770a721a7a2ff00
@@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+ ## [2.1.4] - 2020-12-14
7
+ Common Counter metrics init #71
6
8
 
7
9
  ## [2.1.3] - 2020-12-14
8
10
  Update travis URL in README file #67
@@ -3,18 +3,25 @@ require "prometheus_exporter"
3
3
  require "prometheus_exporter/server"
4
4
  require "prometheus_exporter/client"
5
5
  require "prometheus_exporter/instrumentation"
6
+ require "topological_inventory/providers/common/mixins/statuses"
6
7
 
7
8
  module TopologicalInventory
8
9
  module Providers
9
10
  module Common
10
11
  class Metrics
12
+ include TopologicalInventory::Providers::Common::Mixins::Statuses
13
+
11
14
  ERROR_COUNTER_MESSAGE = "total number of errors".freeze
15
+ ERROR_TYPES = %i[general].freeze
16
+ OPERATIONS = %w[].freeze
12
17
 
13
18
  def initialize(port = 9394)
14
19
  return if port == 0
15
20
 
16
21
  configure_server(port)
17
22
  configure_metrics
23
+
24
+ init_counters
18
25
  end
19
26
 
20
27
  def stop_server
@@ -25,6 +32,10 @@ module TopologicalInventory
25
32
  @error_counter&.observe(1, :type => type.to_s)
26
33
  end
27
34
 
35
+ def record_refresh_timing(labels = {}, &block)
36
+ record_time(@refresh_timer, labels, &block)
37
+ end
38
+
28
39
  def record_operation(name, labels = {})
29
40
  @status_counter&.observe(1, (labels || {}).merge(:name => name))
30
41
  end
@@ -55,6 +66,19 @@ module TopologicalInventory
55
66
 
56
67
  private
57
68
 
69
+ # Set all values to 0 (otherwise the counter is undefined)
70
+ def init_counters
71
+ self.class::ERROR_TYPES.each do |err_type|
72
+ @error_counter&.observe(0, :type => err_type)
73
+ end
74
+
75
+ self.class::OPERATIONS.each do |op|
76
+ operation_status.each_key do |status|
77
+ @status_counter&.observe(0, :name => op, :status => status.to_s)
78
+ end
79
+ end
80
+ end
81
+
58
82
  def configure_server(port)
59
83
  @server = PrometheusExporter::Server::WebServer.new(:port => port)
60
84
  @server.start
@@ -67,10 +91,11 @@ module TopologicalInventory
67
91
  PrometheusExporter::Metric::Base.default_prefix = default_prefix
68
92
 
69
93
  @duration_seconds = PrometheusExporter::Metric::Histogram.new('duration_seconds', 'Duration of processed operation')
94
+ @refresh_timer = PrometheusExporter::Metric::Histogram.new('refresh_time', 'Duration of full refresh')
70
95
  @error_counter = PrometheusExporter::Metric::Counter.new('errors_total', ERROR_COUNTER_MESSAGE)
71
96
  @status_counter = PrometheusExporter::Metric::Counter.new('status_counter', 'number of processed operations')
72
97
 
73
- [@duration_seconds, @error_counter, @status_counter].each do |metric|
98
+ [@duration_seconds, @refresh_timer, @error_counter, @status_counter].each do |metric|
74
99
  @server.collector.register_metric(metric)
75
100
  end
76
101
  end
@@ -1,7 +1,7 @@
1
1
  module TopologicalInventory
2
2
  module Providers
3
3
  module Common
4
- VERSION = "2.1.3".freeze
4
+ VERSION = "2.1.4".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-providers-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Slemr