Sha256: 8b6e48ec1cb41bcf5cece82e877d6efbb29994d5830009f81976bca6fddabcd7

Contents?: true

Size: 950 Bytes

Versions: 26

Compression:

Stored size: 950 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.

require 'new_relic/agent/utilization/vendor'

module NewRelic
  module Agent
    module Utilization
      class GCP < Vendor
        vendor_name "gcp"
        endpoint "http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true"
        headers "Metadata-Flavor" => "Google"
        keys ["id", "machineType", "name", "zone"]
        key_transforms :to_sym

        MACH_TYPE = 'machineType'.freeze
        ZONE = 'zone'.freeze

        def prepare_response response
          body = JSON.parse response.body
          body[MACH_TYPE] = trim_leading body[MACH_TYPE]
          body[ZONE] = trim_leading body[ZONE]
          body
        end

        SLASH = '/'.freeze

        def trim_leading value
          value.split(SLASH).last
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
newrelic_rpm-4.8.0.341 lib/new_relic/agent/utilization/gcp.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/utilization/gcp.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/utilization/gcp.rb
newrelic_rpm-4.6.0.338 lib/new_relic/agent/utilization/gcp.rb
newrelic_rpm-4.5.0.337 lib/new_relic/agent/utilization/gcp.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/utilization/gcp.rb