dawarich/app/services/metrics/archives/points_archived.rb
Evgenii Burmakin 6e9e02388b
Add immediate verification and count validation to raw data archiving (#2138)
* Add immediate verification and count validation to raw data archiving

* Remove verifying job

* Add archive metrics reporting

* Disable RailsPulse in Self-hosted Environments

* Remove user_id and points_count parameters from Metrics::Archives::Operation and related calls.
2026-01-10 00:39:48 +01:00

25 lines
609 B
Ruby

# frozen_string_literal: true
class Metrics::Archives::PointsArchived
def initialize(count:, operation:)
@count = count
@operation = operation # 'added' or 'removed'
end
def call
return unless DawarichSettings.prometheus_exporter_enabled?
metric_data = {
type: 'counter',
name: 'dawarich_archive_points_total',
value: @count,
labels: {
operation: @operation
}
}
PrometheusExporter::Client.default.send_json(metric_data)
rescue StandardError => e
Rails.logger.error("Failed to send points archived metric: #{e.message}")
end
end