Class: Appsignal::Environment Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- SUPPORTED_GEMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[ actioncable activejob capistrano celluloid data_mapper delayed_job mongo_ruby_driver padrino passenger puma que rack rails rake redis resque sequel shoryuken sidekiq sinatra unicorn webmachine ].freeze
Class Method Summary collapse
-
.report(key) ⇒ void
private
Add environment metadata.
- .report_enabled(feature) ⇒ Object private
-
.report_supported_gems ⇒ Object
private
Report on the list of AppSignal supported gems.
Class Method Details
.report(key) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Add environment metadata.
The key and value of the environment metadata must be a String, even if it's actually of another type.
The value of the environment metadata is given as a block that captures errors that might be raised while fetching the value. It will not re-raise errors, but instead log them using the Appsignal.logger. This ensures AppSignal will not cause an error in the application when collecting this metadata.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/appsignal/environment.rb', line 29 def self.report(key) key = case key when String key else Appsignal.logger.error "Unable to report on environment metadata: " \ "Unsupported value type for #{key.inspect}" return end yielded_value = begin yield rescue => e Appsignal.logger.error \ "Unable to report on environment metadata #{key.inspect}:\n" \ "#{e.class}: #{e}" return end value = case yielded_value when TrueClass, FalseClass yielded_value.to_s when String yielded_value else Appsignal.logger.error "Unable to report on environment metadata " \ "#{key.inspect}: Unsupported value type for " \ "#{yielded_value.inspect}" return end Appsignal::Extension.(key, value) rescue => e Appsignal.logger.error "Unable to report on environment metadata:\n" \ "#{e.class}: #{e}" end |
.report_enabled(feature) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
119 120 121 122 123 124 |
# File 'lib/appsignal/environment.rb', line 119 def self.report_enabled(feature) Appsignal::Environment.report("ruby_#{feature}_enabled") { true } rescue => e Appsignal.logger.error "Unable to report integration enabled:\n" \ "#{e.class}: #{e}" end |
.report_supported_gems ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Report on the list of AppSignal supported gems
This list is used to report if which AppSignal supported gems are present in this app and what version. This data will help AppSignal improve its support by knowing what gems and versions of gems it still needs to support or can drop support for.
It will ask Bundler to report name and version information from the gems that are present in the app bundle.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/appsignal/environment.rb', line 104 def self.report_supported_gems return unless defined?(Bundler) # Do nothing if Bundler is not present bundle_gem_specs = ::Bundler.rubygems.all_specs SUPPORTED_GEMS.each do |gem_name| gem_spec = bundle_gem_specs.find { |spec| spec.name == gem_name } next unless gem_spec report("ruby_#{gem_name}_version") { gem_spec.version.to_s } end rescue => e Appsignal.logger.error "Unable to report supported gems:\n" \ "#{e.class}: #{e}" end |