-
Notifications
You must be signed in to change notification settings - Fork 401
Expand file tree
/
Copy pathutils.rb
More file actions
26 lines (24 loc) · 812 Bytes
/
utils.rb
File metadata and controls
26 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true
module Datadog
module Core
module Contrib
module Rails
# common utilities for Rails
module Utils
def self.app_name
namespace_method = (::Rails::VERSION::MAJOR >= 6) ? :module_parent_name : :parent_name
application_name = ::Rails.application.class.public_send(namespace_method)
application_name&.underscore
rescue
# Adds a failsafe during app boot, teardown, or test stubs where the application is not initialized and this check gets performed
Datadog.logger.debug('Failed to extract Rails application name.')
nil
end
def self.railtie_supported?
!!defined?(::Rails::Railtie)
end
end
end
end
end
end