diff --git a/app/jobs/jobs/prometheus_customer_auth_stats.rb b/app/jobs/jobs/prometheus_customer_auth_stats.rb index 95027b406..a230a09bc 100644 --- a/app/jobs/jobs/prometheus_customer_auth_stats.rb +++ b/app/jobs/jobs/prometheus_customer_auth_stats.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'prometheus/active_calls_processor' +require 'prometheus/customer_auth_processor' module Jobs class PrometheusCustomerAuthStats < ::BaseJob @@ -9,8 +9,8 @@ class PrometheusCustomerAuthStats < ::BaseJob def execute client = PrometheusExporter::Client.default Stats::CustomerAuthStats.last24_hour.each do |stat| - metric = ActiveCallsProcessor.collect( - last24h_customer_price: stat.customer_price, + metric = CustomerAuthProcessor.collect( + last24h_customer_price: stat.customer_price.to_f, labels: { account_id: stat.account_id, account_external_id: stat.account_external_id, diff --git a/app/models/stats/customer_auth_stats.rb b/app/models/stats/customer_auth_stats.rb index 5398bacfa..8505d8608 100644 --- a/app/models/stats/customer_auth_stats.rb +++ b/app/models/stats/customer_auth_stats.rb @@ -33,7 +33,7 @@ class Stats::CustomerAuthStats < Stats::Traffic belongs_to :customer_auth, class_name: 'CustomersAuth', optional: true def self.last24_hour - from_time = 24.hours.ago.beginning_of_hour + from_time = 23.hours.ago.beginning_of_hour stats = where('timestamp >= ?', from_time) .group(:customer_auth_id) diff --git a/lib/prometheus/custom_auth_processor.rb b/lib/prometheus/customer_auth_processor.rb similarity index 100% rename from lib/prometheus/custom_auth_processor.rb rename to lib/prometheus/customer_auth_processor.rb diff --git a/spec/jobs/jobs/prometheus_customer_auth_stats_spec.rb b/spec/jobs/jobs/prometheus_customer_auth_stats_spec.rb index d4b76f313..cd95fcea0 100644 --- a/spec/jobs/jobs/prometheus_customer_auth_stats_spec.rb +++ b/spec/jobs/jobs/prometheus_customer_auth_stats_spec.rb @@ -47,7 +47,7 @@ it 'sends prometheus metrics' do expect { subject }.to send_prometheus_metrics .exactly(3) - .with(type: 'yeti_ac', + .with(type: 'yeti_ca', last24h_customer_price: 0.3, metric_labels: { account_id: account1.id, @@ -56,7 +56,7 @@ customer_auth_external_id: customer_auth1.external_id, customer_auth_external_type: customer_auth1.external_type }) - .with(type: 'yeti_ac', + .with(type: 'yeti_ca', last24h_customer_price: 0.4, metric_labels: { account_id: account2.id, @@ -65,7 +65,7 @@ customer_auth_external_id: customer_auth2.external_id, customer_auth_external_type: customer_auth2.external_type }) - .with(type: 'yeti_ac', + .with(type: 'yeti_ca', last24h_customer_price: 0.5, metric_labels: { account_id: account3.id, diff --git a/spec/models/stats/customer_auth_stats_spec.rb b/spec/models/stats/customer_auth_stats_spec.rb index 645da32a8..bbf627aeb 100644 --- a/spec/models/stats/customer_auth_stats_spec.rb +++ b/spec/models/stats/customer_auth_stats_spec.rb @@ -16,9 +16,9 @@ let(:customer_auth3) { FactoryBot.create(:customers_auth, **customer_auth3_attrs) } let(:customer_auth3_attrs) { { account: account_internal, external_id: nil, external_type: nil } } - let(:timestamp_24_hours_ago) { 24.hours.ago.beginning_of_hour } + let(:timestamp_24_hours_ago) { 23.hours.ago.beginning_of_hour } let(:timestamp_now) { Time.now } - let(:timestamp_early_than_24_hours) { 24.hours.ago.beginning_of_hour - 1.second } + let(:timestamp_early_than_24_hours) { 23.hours.ago.beginning_of_hour - 1.second } let!(:ca_stats1) do [