1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 05:25:24 +02:00

Tweak exception logging, sync stale behavior

This commit is contained in:
Zach Gollwitzer 2025-05-18 10:19:15 -04:00
parent 9f13b5bb83
commit 29a8ac9d8a
6 changed files with 46 additions and 26 deletions

View file

@ -26,9 +26,16 @@ class Security::Price::Importer
prev_price_value = start_price_value
unless prev_price_value.present?
error = MissingStartPriceError.new("Could not find a start price for #{security.ticker} on or before #{start_date}")
Rails.logger.error(error.message)
Sentry.capture_exception(error)
Rails.logger.error("Could not find a start price for #{security.ticker} on or before #{start_date}")
Sentry.capture_exception(MissingStartPriceError.new("Could not determine start price for ticker")) do |scope|
scope.set_tags(security_id: security.id)
scope.set_context("security", {
id: security.id,
start_date: start_date
})
end
return 0
end
@ -75,9 +82,12 @@ class Security::Price::Importer
if response.success?
response.data.index_by(&:date)
else
msg = "#{security_provider.class.name} could not fetch prices for #{security.ticker} between #{provider_fetch_start_date} and #{end_date}. Provider error: #{response.error.message}"
Rails.logger.warn(msg)
Sentry.capture_exception(MissingSecurityPriceError.new(msg), level: :warning)
Rails.logger.warn("#{security_provider.class.name} could not fetch prices for #{security.ticker} between #{provider_fetch_start_date} and #{end_date}. Provider error: #{response.error.message}")
Sentry.capture_exception(MissingSecurityPriceError.new("Could not fetch prices for ticker"), level: :warning) do |scope|
scope.set_tags(security_id: security.id)
scope.set_context("security", { id: security.id, start_date: start_date, end_date: end_date })
end
{}
end
end