Sha256: eab83b4a0b231a243eb2f87096ef52804866820bdfa3ed1d04504e1e10747882

Contents?: true

Size: 855 Bytes

Versions: 13

Compression:

Stored size: 855 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module Hostname
      def self.get
        dyno_name = ENV['DYNO']
        if dyno_name && ::NewRelic::Agent.config[:'heroku.use_dyno_names']
          matching_prefix = heroku_dyno_name_prefix(dyno_name)
          dyno_name = "#{matching_prefix}.*" if matching_prefix
          dyno_name
        else
          Socket.gethostname
        end
      end

      def self.heroku_dyno_name_prefix(dyno_name)
        get_dyno_prefixes.find do |dyno_prefix|
          dyno_name.start_with?(dyno_prefix + ".")
        end
      end

      def self.get_dyno_prefixes
        ::NewRelic::Agent.config[:'heroku.dyno_name_prefixes_to_shorten']
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
newrelic_rpm-3.14.0.305 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.12.1.298 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.12.0.288 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.11.2.286 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.11.1.284 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.11.0.283 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.10.0.279 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.9.9.275 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.9.8.273 lib/new_relic/agent/hostname.rb
newrelic_rpm-3.9.7.266 lib/new_relic/agent/hostname.rb