Compare commits

...

2 commits

9 changed files with 29 additions and 38 deletions

View file

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Fixed
- Routes are now being drawn the very same way on Map V2 as in Map V1. #2132 #2086
- RailsPulse performance monitoring is now disabled for self-hosted instances. It fixes poor performance on Synology. #2139
## Changed

View file

@ -3,11 +3,9 @@
class Metrics::Archives::Operation
OPERATIONS = %w[archive verify clear restore].freeze
def initialize(operation:, status:, user_id: nil, points_count: 0)
def initialize(operation:, status:)
@operation = operation
@status = status # 'success' or 'failure'
@user_id = user_id
@points_count = points_count
@status = status # 'success' or 'failure'
end
def call

View file

@ -26,13 +26,10 @@ module Points
end
def archive_specific_month(user_id, year, month)
month_data = {
'user_id' => user_id,
'year' => year,
'month' => month
}
process_month(month_data)
# Direct call without error handling - allows errors to propagate
# This is intended for use in tests and manual operations where
# we want to know immediately if something went wrong
archive_month(user_id, year, month)
end
private
@ -83,8 +80,7 @@ module Points
# Report successful archive operation
Metrics::Archives::Operation.new(
operation: 'archive',
status: 'success',
user_id: user_id
status: 'success'
).call
true
@ -99,8 +95,7 @@ module Points
# Report failed archive operation
Metrics::Archives::Operation.new(
operation: 'archive',
status: 'failure',
user_id: user_id
status: 'failure'
).call
end
@ -117,7 +112,7 @@ module Points
verification_result = verify_archive_immediately(archive, point_ids)
unless verification_result[:success]
Rails.logger.error("Immediate verification failed: #{verification_result[:error]}")
archive.destroy # Cleanup failed archive
archive.destroy # Cleanup failed archive
raise StandardError, "Archive verification failed: #{verification_result[:error]}"
end
@ -206,7 +201,7 @@ module Points
year: year,
month: month,
chunk_number: chunk_number,
point_count: actual_count, # Use actual count, not assumed
point_count: actual_count, # Use actual count, not assumed
point_ids_checksum: calculate_checksum(point_ids),
archived_at: Time.current,
metadata: {

View file

@ -78,9 +78,7 @@ module Points
# Report successful clear operation
Metrics::Archives::Operation.new(
operation: 'clear',
status: 'success',
user_id: archive.user_id,
points_count: cleared_count
status: 'success'
).call
# Report points removed (cleared from database)
@ -95,8 +93,7 @@ module Points
# Report failed clear operation
Metrics::Archives::Operation.new(
operation: 'clear',
status: 'failure',
user_id: archive.user_id
status: 'failure'
).call
end

View file

@ -21,9 +21,7 @@ module Points
# Report successful restore operation
Metrics::Archives::Operation.new(
operation: 'restore',
status: 'success',
user_id: user_id,
points_count: total_points
status: 'success'
).call
# Report points restored (removed from archived state)
@ -35,8 +33,7 @@ module Points
# Report failed restore operation
Metrics::Archives::Operation.new(
operation: 'restore',
status: 'failure',
user_id: user_id
status: 'failure'
).call
raise

View file

@ -52,8 +52,7 @@ module Points
# Report successful verification operation
Metrics::Archives::Operation.new(
operation: 'verify',
status: 'success',
user_id: archive.user_id
status: 'success'
).call
# Report verification duration
@ -69,8 +68,7 @@ module Points
# Report failed verification operation
Metrics::Archives::Operation.new(
operation: 'verify',
status: 'failure',
user_id: archive.user_id
status: 'failure'
).call
# Report verification duration with check name
@ -85,8 +83,7 @@ module Points
# Report failed verification operation
Metrics::Archives::Operation.new(
operation: 'verify',
status: 'failure',
user_id: archive.user_id
status: 'failure'
).call
# Report verification duration

View file

@ -3,8 +3,8 @@ RailsPulse.configure do |config|
# GLOBAL CONFIGURATION
# ====================================================================================================
# Enable or disable Rails Pulse
config.enabled = true
# Disable Rails Pulse in Self-hosted Environments
config.enabled = !SELF_HOSTED
# ====================================================================================================
# THRESHOLDS

View file

@ -9,7 +9,14 @@ FactoryBot.define do
point_count { 100 }
point_ids_checksum { Digest::SHA256.hexdigest('1,2,3') }
archived_at { Time.current }
metadata { { format_version: 1, compression: 'gzip' } }
metadata do
{
format_version: 1,
compression: 'gzip',
expected_count: point_count,
actual_count: point_count
}
end
after(:build) do |archive|
# Attach a test file

View file

@ -5,9 +5,8 @@ require 'prometheus_exporter/client'
RSpec.describe Metrics::Archives::Operation do
describe '#call' do
subject(:operation) { described_class.new(operation: operation_type, status: status, user_id: user_id).call }
subject(:operation) { described_class.new(operation: operation_type, status: status).call }
let(:user_id) { 123 }
let(:operation_type) { 'archive' }
let(:status) { 'success' }
let(:prometheus_client) { instance_double(PrometheusExporter::Client) }