lib/fluent/plugin/common.rb
# Determine what platform we are running on by consulting the metadata
# service (unless the user has explicitly disabled using that).
Determine what platform we are running on by consulting the metadata
service (unless the user has explicitly disabled using that).
Determine what platform we are running on by consulting the metadata service ( unless the user has explicitly disabled using that ) .
def detect_platform(use_metadata_service)
      unless use_metadata_service
        @log.info 'use_metadata_service is false; not detecting platform'
        return Platform::OTHER
      end
      begin
        open('http://' + METADATA_SERVICE_ADDR, proxy: false) do |f|
          if f.meta['metadata-flavor'] == 'Google'
            @log.info 'Detected GCE platform'
            return Platform::GCE
          end
          if f.meta['server'] == 'EC2ws'
            @log.info 'Detected EC2 platform'
            return Platform::EC2
          end
        end
      rescue StandardError => e
        @log.error 'Failed to access metadata service: ', error: e
      end
      @log.info 'Unable to determine platform'
      Platform::OTHER
    end
def detect_platform ( use_metadata_service ) unless use_metadata_service @log . info 'use_metadata_service is false; not detecting platform' return Platform :: OTHER end begin open ( 'http://' + METADATA_SERVICE_ADDR , proxy : false ) do | f | if f . meta [ 'metadata-flavor' ] == 'Google' @log . info 'Detected GCE platform' return Platform :: GCE end if f . meta [ 'server' ] == 'EC2ws' @log . info 'Detected EC2 platform' return Platform :: EC2 end end rescue StandardError => e @log . error 'Failed to access metadata service: ' , error : e end @log . info 'Unable to determine platform' Platform :: OTHER end
Determine what platform we are running on by consulting the metadata
service (unless the user has explicitly disabled using that).
Determine what platform we are running on by consulting the metadata service ( unless the user has explicitly disabled using that ) .
use_metadata_service
<not_specific>