Module: NatsWork::Monitoring::Setup
- Defined in:
- lib/natswork/monitoring.rb
Overview
Monitoring setup helpers
Class Method Summary collapse
- .new_relic ⇒ Object
- .prometheus(port: 9090, path: '/metrics') ⇒ Object
- .statsd(host: 'localhost', port: 8125, prefix: 'natswork') ⇒ Object
- .webhook(url, options = {}) ⇒ Object
Class Method Details
.new_relic ⇒ Object
339 340 341 342 343 |
# File 'lib/natswork/monitoring.rb', line 339 def self.new_relic reporter = NewRelicReporter.new Coordinator.global.add_reporter(reporter) reporter end |
.prometheus(port: 9090, path: '/metrics') ⇒ Object
311 312 313 314 315 316 |
# File 'lib/natswork/monitoring.rb', line 311 def self.prometheus(port: 9090, path: '/metrics') exporter = PrometheusExporter.new(port: port, path: path) exporter.start_server Coordinator.global.add_reporter(exporter) exporter end |
.statsd(host: 'localhost', port: 8125, prefix: 'natswork') ⇒ Object
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/natswork/monitoring.rb', line 318 def self.statsd(host: 'localhost', port: 8125, prefix: 'natswork') reporter = StatsDReporter.new(host, port, prefix) # Wire up metrics to StatsD metrics_collector = Class.new(MetricsCollector) do define_method(:initialize) { @reporter = reporter } define_method(:collect) do |type, metric, value, | case type when :counter then @reporter.report_counter(metric, value, ) when :gauge then @reporter.report_gauge(metric, value, ) when :timer then @reporter.report_timer(metric, value, ) when :histogram then @reporter.report_histogram(metric, value, ) end end end Metrics.global.add_collector(metrics_collector.new) reporter end |
.webhook(url, options = {}) ⇒ Object
345 346 347 348 349 |
# File 'lib/natswork/monitoring.rb', line 345 def self.webhook(url, = {}) reporter = WebhookReporter.new(url, ) Coordinator.global.add_reporter(reporter) reporter end |