Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ OHLOH_ANALYTICS_CLIENT_REGISTRATION_ID=

JWT_SECRET=
COVERITY_SCAN_URL = 'https://scan.coverity.com'
DATADOG_LOGGER_PATH = STDOUT
APP_LOGGER_PATH = STDOUT
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ end

group :production, :staging do
gem 'activerecord-nulldb-adapter', require: false
gem 'datadog', '~> 2.2'
end

group :development, :staging do
Expand Down
21 changes: 0 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1803,13 +1803,6 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
datadog (2.19.0)
datadog-ruby_core_source (~> 3.4, >= 3.4.1)
libdatadog (~> 18.1.0.1.0)
libddwaf (~> 1.24.1.0.3)
logger
msgpack
datadog-ruby_core_source (3.4.1)
date (3.4.1)
docile (1.4.1)
doorkeeper (5.8.2)
Expand Down Expand Up @@ -1922,19 +1915,6 @@ GEM
letter_opener (~> 1.9)
railties (>= 6.1)
rexml
libdatadog (18.1.0.1.0)
libdatadog (18.1.0.1.0-aarch64-linux)
libdatadog (18.1.0.1.0-x86_64-linux)
libddwaf (1.24.1.0.3)
ffi (~> 1.0)
libddwaf (1.24.1.0.3-aarch64-linux)
ffi (~> 1.0)
libddwaf (1.24.1.0.3-arm64-darwin)
ffi (~> 1.0)
libddwaf (1.24.1.0.3-x86_64-darwin)
ffi (~> 1.0)
libddwaf (1.24.1.0.3-x86_64-linux)
ffi (~> 1.0)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand Down Expand Up @@ -2209,7 +2189,6 @@ DEPENDENCIES
coffee-rails
coffee-script-source (~> 1.8.0)
database_cleaner
datadog (~> 2.2)
doorkeeper (~> 5.5)
dotenv-rails
factory_bot_rails
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/knowledge_base_status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def sync
exchange = KnowledgeBaseQueue.get_exchange(conn)
display_kb_message(exchange)
rescue StandardError => e
Rails.logger.info(e.message)
AppLogger.info(e.message)
Airbrake.notify(e)
render json: { message: e.message }, status: :bad_request
ensure
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def validate_request_format
request.env[:user_agent] = request.user_agent
case exception
when SocketError, Errno::ECONNREFUSED, FisbotApiError
DataDogReport.error(exception.backtrace.to_s)
AppLogger.error(exception.backtrace.to_s)
flash[:notice] = t(:api_exception)
redirect_to_saved_path
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def retries_remaining
def disable_account_and_notify_admin
account.update!(level: Account::Access::DISABLED)
AccountMailer.notify_disabled_account_for_login_failure(account).deliver_now
DataDogReport.info("#{account.login} deactivated for repeated failed login attempts.")
AppLogger.info("#{account.login} deactivated for repeated failed login attempts.")
end

def increment_auth_fail_count
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/markdown_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def markdown_format(text)
markdown = Redcarpet::Markdown.new(renderer, extensions)
markdown.render(text).html_safe
rescue StandardError
Rails.logger.error "Redcarpet failed to convert:\n#{text}."
AppLogger.error "Redcarpet failed to convert:\n#{text}."
text.to_s
end
end
17 changes: 17 additions & 0 deletions app/lib/app_logger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module AppLogger
module_function

def logger
@logger ||= Logger.new(ENV.fetch('APP_LOGGER_PATH', nil))
end

def info(message)
logger.info(message)
end

def error(message)
logger.error(message)
end
end
13 changes: 0 additions & 13 deletions app/lib/data_dog_report.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/lib/fisbot/api_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def available?
response = Net::HTTP.get_response(uri)
response.code == '200' && set_uptime_verified_time
rescue Errno::ECONNREFUSED, Resolv::ResolvError
DataDogReport.error("Fisbot API outage: #{Time.now.utc}")
AppLogger.error("Fisbot API outage: #{Time.now.utc}")
false
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/account/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def destroy_spammer_dependencies(account)
def safe_undo(edit)
Edit.transaction(requires_new: true) { edit.undo!(Account.hamster) if edit.allow_undo? }
rescue StandardError
Rails.logger.info "Spam undo failed: #{$ERROR_INFO.inspect}\n#{edit.inspect}"
AppLogger.info "Spam undo failed: #{$ERROR_INFO.inspect}\n#{edit.inspect}"
end

def dependent_destroy(account)
Expand Down
7 changes: 0 additions & 7 deletions config/initializers/datadog.rb

This file was deleted.

14 changes: 7 additions & 7 deletions db/migrate/20170616152705_set_codelocation_status_to_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setup_temp_table
end

def load_temp_table_data
DataDogReport.info ' loading temp table..'
AppLogger.info ' loading temp table..'
@conn.execute("CREATE temp table kbLocations
(id integer);")

Expand All @@ -53,7 +53,7 @@ def load_temp_table_data
end

def index_temp_table
DataDogReport.info ' indexing temp table....'
AppLogger.info ' indexing temp table....'
@conn.execute('CREATE INDEX ON kbLocations (id)')
end

Expand All @@ -66,11 +66,11 @@ def get_possible_selection
NOT EXISTS
(SELECT id FROM kbLocations kb WHERE kb.id = cl.id);")
message = " updating #{code_location_count} code location records"
DataDogReport.info message
AppLogger.info message
end

def update_code_location_status
DataDogReport.info ' updating code location status.....'
AppLogger.info ' updating code location status.....'
get_possible_selection
@conn.execute("UPDATE Code_Locations cl SET status = #{CodeLocation::STATUS_UNDEFINED}
WHERE status != #{CodeLocation::STATUS_DELETED} AND
Expand All @@ -79,7 +79,7 @@ def update_code_location_status
end

def rollback_code_location_status
DataDogReport.info ' rolling back code location status.....'
AppLogger.info ' rolling back code location status.....'
get_possible_selection
@conn.execute("UPDATE Code_Locations cl SET status = #{CodeLocation::STATUS_ACTIVE}
WHERE status = #{CodeLocation::STATUS_UNDEFINED} AND
Expand All @@ -88,8 +88,8 @@ def rollback_code_location_status
end

def drop_temp_table
DataDogReport.info ' dropping temp table.......'
AppLogger.info ' dropping temp table.......'
@conn.execute('DROP table kbLocations;')
DataDogReport.info 'completed'
AppLogger.info 'completed'
end
end
50 changes: 0 additions & 50 deletions fixtures/vcr_cassettes/datadog_error_request.yml

This file was deleted.

2 changes: 1 addition & 1 deletion lib/openhub_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def self.get_response(url)
response = http.request(request)
response = JSON.parse(response.read_body)
rescue SocketError => e
Rails.logger.error("OpenhubSecurity SocketError Exception: #{e.message}")
AppLogger.error("OpenhubSecurity SocketError Exception: #{e.message}")
end
response || {}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/cleanup_vulnerabilities.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ task cleanup_vulnerabilities: :environment do
puts "Iteration ##{i} completed."
i += 1
rescue StandardError => e
Rails.logger.info(e.message)
AppLogger.info(e.message)
end
end
10 changes: 5 additions & 5 deletions lib/tasks/home_page_stats.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

desc 'Updates the required Home Page stats'
task home_page_stats: :environment do
Rails.logger.info('Running home_page_stats task')
AppLogger.info('Running home_page_stats task')
contributors = Account.recently_active.includes(best_account_analysis: [:name_fact])
accounts_ids = contributors.map(&:id)
accounts = Account.where(id: accounts_ids).index_by(&:id).values_at(*accounts_ids)
Rails.cache.write('HomeDecorator-recently_active_accounts-cache', accounts)

Rails.logger.info('caching vita count')
AppLogger.info('caching vita count')
account_analysis_count = contributors.map { |c| c.best_account_analysis&.name_fact&.thirty_day_commits }
Rails.cache.write('HomeDecorator-vita_count-cache', account_analysis_count)

Expand All @@ -19,19 +19,19 @@ task home_page_stats: :environment do
end

def write_most_active_cache
Rails.logger.info('caching most active projects')
AppLogger.info('caching most active projects')
ids = Project.most_active.where(analyses: { updated_on: 6.months.ago.. })
.includes(:logo, best_analysis: %i[main_language thirty_day_summary]).pluck(:id)
Rails.cache.write('HomeDecorator-most_active_projects-cache', ids)
end

def write_person_count_cache
Rails.logger.info('caching person count')
AppLogger.info('caching person count')
Rails.cache.write('HomeDecorator-person_count-cache', Person.count)
end

def write_active_project_count_cache
Rails.logger.info('caching active_project_count')
AppLogger.info('caching active_project_count')
Rails.cache.write('HomeDecorator-active_project_count-cache', Project.active.count)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/kb_updater.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace :kb_updater do
puts "#{count} projects updated"
conn.close
rescue StandardError => e
Rails.logger.info(e.message)
AppLogger.info(e.message)
Airbrake.notify(e)
conn.close
raise StandardError, e.message # trigger healthchecks.io ping.
Expand Down
2 changes: 1 addition & 1 deletion script/add_apache_github_code_locations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_code_location(url)
hsh = JSON.parse(response.body)
hsh['code_location_id']
rescue StandardError => e
DataDogReport.error e.message
AppLogger.error e.message
end

def git_branch(url)
Expand Down
2 changes: 1 addition & 1 deletion script/create_sbom_jobs_for_projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def perform(limit)
project_id: project.id, priority: PRIORITY)
end

DataDogReport.info "Created SbomJobs for the project => #{project.id}: #{project.vanity_url}"
AppLogger.info "Created SbomJobs for the project => #{project.id}: #{project.vanity_url}"
end
end

Expand Down
4 changes: 2 additions & 2 deletions script/create_scan_project_in_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def handle_response(project_id, row)
end

def create_code_location_scan(project_id, row)
DataDogReport.info "Project Value #{project_id} row value #{row['name']}"
AppLogger.info "Project Value #{project_id} row value #{row['name']}"

code_location_id = Enlistment.not_deleted.where(project_id: project_id,
code_location_id: @code_location_ids).first&.code_location_id
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_result(uri, params)
response = Net::HTTP.post_form(uri, params)
[JSON.parse(response.body), response.code]
rescue StandardError => e
DataDogReport.error e.message
AppLogger.error e.message
nil
end
end
Expand Down
8 changes: 4 additions & 4 deletions script/delete_google_code_projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ def initialize

# rubocop:disable Metrics/MethodLength
def execute
DataDogReport.info 'starting script'
AppLogger.info 'starting script'
@project_ids = fetch_googlecode_projects_array
DataDogReport.info "Attempting to delete #{@project_ids.length} google code projects"
AppLogger.info "Attempting to delete #{@project_ids.length} google code projects"

# update project deleted field for all googlecode projects in batches of 1000
until (projects = Project.find(@project_ids.slice!(0..999))).empty?
projects.each do |project|
undo_project(project)
end
end
DataDogReport.info(
AppLogger.info(
'Successfully completed script - Please check deleted_googlecode_log_file.log to view any exceptions'
)
end
Expand All @@ -43,7 +43,7 @@ def fetch_googlecode_projects_array
end

def undo_project(project)
DataDogReport.info "Processing project #{project.id}"
AppLogger.info "Processing project #{project.id}"
begin
project.tags.delete_all
project.create_edit.undo!(@editor) if project.create_edit.allow_undo?
Expand Down
Loading
Loading