mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
22 lines
631 B
Ruby
22 lines
631 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Metrics::Archives::CompressionRatio
|
|
def initialize(original_size:, compressed_size:)
|
|
@ratio = compressed_size.to_f / original_size.to_f
|
|
end
|
|
|
|
def call
|
|
return unless DawarichSettings.prometheus_exporter_enabled?
|
|
|
|
metric_data = {
|
|
type: 'histogram',
|
|
name: 'dawarich_archive_compression_ratio',
|
|
value: @ratio,
|
|
buckets: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
|
|
}
|
|
|
|
PrometheusExporter::Client.default.send_json(metric_data)
|
|
rescue StandardError => e
|
|
Rails.logger.error("Failed to send compression ratio metric: #{e.message}")
|
|
end
|
|
end
|