Skip to content

Commit

Permalink
Fix autoload not picking up prometheus.rb (#5478)
Browse files Browse the repository at this point in the history
**Story card:**
[sc-13408](https://app.shortcut.com/simpledotorg/story/13408/migrate-pending-custom-metrics-to-prometheus-from-datadog)

## Because

The Zeitwork mode is failing to load the prometheus.rb file in
production environments. Even though other .rb files are working fine.

## This addresses

As a temporary fix, we'll move Prometheus within the Metrics module
  • Loading branch information
danySam authored Oct 3, 2024
1 parent 69afefb commit a3aa67b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 18 additions & 0 deletions lib/metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,22 @@ def benchmark_and_record_metric(type, event, labels, description)
elapsed_time_seconds = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
record_metric(type, event, elapsed_time_seconds, labels, description)
end

class Prometheus
include Singleton

def initialize
@client = PrometheusExporter::Client.default
@collectors = {}
end

def register(type, name, description = nil)
@collectors[name] ||= @client.register(type, name, description)
self
end

def observe(name, value, labels = {})
@collectors[name].observe(value, labels)
end
end
end
18 changes: 0 additions & 18 deletions lib/prometheus.rb

This file was deleted.

0 comments on commit a3aa67b

Please sign in to comment.