fluent-plugin-jfrog-metrics 0.2.11 → 0.2.12.1

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: cb8dfdd51ee10875ad7d6ec7c539a92ebc703061e4bc87aa407229ebb1b97898
4
- data.tar.gz: b5f7c2a0121c9100a579f6ce61d5845ae6058656f06031d06dbc4800a7b8bfe3
3
+ metadata.gz: e3874d94d40532a3bb834c0b5c7fa4e999a81d9ac9446fbfdf5787a43243b1b3
4
+ data.tar.gz: 56639f48a7989af20ad9444a90f036a17efbfd0d5dd4a053d9c2170506e2e705
5
5
  SHA512:
6
- metadata.gz: a7fca5a309cb9c334116019c7914456870f31aa1ca8adcadb8803932327bea1a0d8ecfd6cd4f36346b6c3904dc83c795618877a2ceca8a78bcd4ae3a6d3ab667
7
- data.tar.gz: 8ed3af580a9cea432a5a66983c5c87e2c28b46134f3772e4fdc9b712bdd55ca75ea4ca8247cd2bdbbf426a13e6982d4dee69151ab96b39d7f8f55dd040749c1e
6
+ metadata.gz: 167edf56bbab4ea71298eab1972b0dedfa437939dd617619f5b344f257dfe804b5a7634f35aa69fe27c0fa2a412af7b8e25a102e857b8a16febba9c346654e1e
7
+ data.tar.gz: 7485f266e6a5d9c987cc60f9326aa872e2f3ca6c0fc31968f29912f88c9f701990b83a4de08eaf633fc69279940b6d315d5efcb9b4533c0b0df87de960af4a7a
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gemspec
7
7
  group :test do
8
8
  gem 'minitest'
9
9
  gem 'minitest-reporters', '>= 0.5.0'
10
- gem 'rest-client', '>= 2.1.0'
10
+ gem 'rest-client', '~> 2.1.0'
11
11
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-jfrog-metrics (0.2.11)
4
+ fluent-plugin-jfrog-metrics (0.2.12.1)
5
5
  fluentd (>= 0.14.10, < 2)
6
6
  rest-client (~> 2.1.0)
7
7
 
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'fluent-plugin-jfrog-metrics'
6
- spec.version = '0.2.11'
6
+ spec.version = '0.2.12.1'
7
7
  spec.authors = ['MahithaB, BenHarosh']
8
8
  spec.email = ['cpe-support@jfrog.com']
9
9
 
@@ -43,6 +43,8 @@ module Fluent
43
43
  config_param :common_jpd, :bool, default: false
44
44
  config_param :verify_ssl, :bool, default: true
45
45
 
46
+ $logger = nil
47
+
46
48
  # `configure` is called before `start`.
47
49
  # 'conf' is a `Hash` that includes the configuration parameters.
48
50
  # If the configuration is invalid, raise `Fluent::ConfigError`.
@@ -71,8 +73,9 @@ module Fluent
71
73
  def start
72
74
  super
73
75
  @running = true
76
+ $logger = log
74
77
  @thread = Thread.new do
75
- run(log)
78
+ run
76
79
  end
77
80
  end
78
81
 
@@ -82,28 +85,34 @@ module Fluent
82
85
  super
83
86
  end
84
87
 
85
- def run(logger)
86
- logger.info("Preparing metrics collection, creating timer task")
88
+ def run
89
+ $logger.info("Preparing metrics collection, creating timer task")
87
90
  timer_task = Concurrent::TimerTask.new(execution_interval: @execution_interval, run_now: true) do
88
- logger.info("Timer task execution started")
89
- do_execute(logger)
90
- logger.info("Timer task execution finished")
91
+ begin
92
+ $logger.info("Timer task execution started")
93
+ do_execute
94
+ next "Timer task execution finished successfully"
95
+ rescue => e
96
+ $logger.error("Error occurred when running Timer task: #{e.message}")
97
+ raise e
98
+ end
91
99
  end
100
+ # timer_task.add_observer(TaskObserver.new)
92
101
  timer_task.execute
93
102
  sleep 100
94
103
  end
95
104
 
96
- def do_execute(logger)
105
+ def do_execute
97
106
  begin
98
- logger.info("Metrics collection started")
99
- metrics_helper = MetricsHelper.new(logger, @metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd, @verify_ssl, @request_timeout)
107
+ $logger.info("Metrics collection started")
108
+ metrics_helper = MetricsHelper.new($logger, @metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd, @verify_ssl, @request_timeout)
100
109
  platform_metrics = metrics_helper.get_metrics
101
110
 
102
111
  additional_metrics = metrics_helper.get_additional_metrics
103
112
  if !additional_metrics.nil? && additional_metrics != ''
104
113
  platform_metrics += additional_metrics.to_s
105
114
  end
106
- logger.info("Metrics collection finished")
115
+ $logger.info("Metrics collection finished")
107
116
 
108
117
  if @target_platform == 'SPLUNK'
109
118
  parser = SplunkMetricsParser.new(@metric_prefix, router, @tag)
@@ -114,24 +123,34 @@ module Fluent
114
123
  else
115
124
  raise 'Parser Type is not valid. target_platform Should be SPLUNK or NEWRELIC or DATADOG'
116
125
  end
117
- logger.debug("Emitting collected metrics started")
126
+ $logger.debug("Emitting collected metrics started")
118
127
  parser.emit_parsed_metrics(platform_metrics)
119
- logger.debug("Emitting collected metrics finished")
128
+ $logger.debug("Emitting collected metrics finished")
120
129
 
121
130
  rescue RestClient::Exceptions::OpenTimeout
122
- logger.info("The request timed out while trying to open a connection. The configured request timeout is: #{@request_timeout}")
131
+ $logger.error("The request timed out while trying to open a connection. The configured request timeout is: #{@request_timeout}")
123
132
  rescue RestClient::Exceptions::ReadTimeout
124
- logger.info("The request timed out while waiting for a response. The configured request timeout is: #{@request_timeout}")
133
+ $logger.error("The request timed out while waiting for a response. The configured request timeout is: #{@request_timeout}")
125
134
  rescue RestClient::Exceptions::RequestTimeout
126
- logger.info("The request timed out. The configured request timeout is: #{@request_timeout}")
135
+ $logger.error("The request timed out. The configured request timeout is: #{@request_timeout}")
127
136
  rescue RestClient::ExceptionWithResponse => e
128
- logger.info("HTTP request failed: #{e.response}")
137
+ $logger.error("HTTP request failed: #{e.response}")
129
138
  rescue StandardError => e
130
- logger.info("An unexpected error occurred during metrics collection: #{e.message}")
139
+ $logger.error("An unexpected error occurred during metrics collection: #{e.message}")
131
140
  else
132
- logger.debug("Metrics collection and emission do_execute finished with no errors")
141
+ $logger.debug("Metrics collection and emission do_execute finished with no errors")
133
142
  end
134
143
  end
144
+
145
+ # class TaskObserver
146
+ # def update(time, result, e)
147
+ # if result
148
+ # $logger.info("Timer task Execution successfully returned: '#{result}' at: #{time}")
149
+ # else
150
+ # $logger.error("Timer task Execution failed with error: #{e} at: #{time}")
151
+ # end
152
+ # end
153
+ # end
135
154
  end
136
155
  end
137
156
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-jfrog-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MahithaB, BenHarosh