Skip to content

Commit

Permalink
fix PrometheusCustomerAuthStats metrics and stats
Browse files Browse the repository at this point in the history
  • Loading branch information
senid231 committed Jun 30, 2023
1 parent 8fd7864 commit 96fa9a8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/jobs/jobs/prometheus_customer_auth_stats.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'prometheus/active_calls_processor'
require 'prometheus/customer_auth_processor'

module Jobs
class PrometheusCustomerAuthStats < ::BaseJob
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/models/stats/customer_auth_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions spec/jobs/jobs/prometheus_customer_auth_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions spec/models/stats/customer_auth_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down

0 comments on commit 96fa9a8

Please sign in to comment.