lib/fluent/plugin/monitoring.rb in fluent-plugin-google-cloud-0.7.29 vs lib/fluent/plugin/monitoring.rb in fluent-plugin-google-cloud-0.7.30
- old
+ new
@@ -47,11 +47,11 @@
end
end
# Base class for the monitoring registry.
class BaseMonitoringRegistry
- def initialize(_project_id, _monitored_resource)
+ def initialize(_project_id, _monitored_resource, _gcm_service_address)
end
def counter(_name, _labels, _docstring)
BaseCounter.new
end
@@ -66,11 +66,11 @@
class PrometheusMonitoringRegistry < BaseMonitoringRegistry
def self.name
'prometheus'
end
- def initialize(_project_id, _monitored_resource)
+ def initialize(_project_id, _monitored_resource, _gcm_service_address)
super
require 'prometheus/client'
@registry = Prometheus::Client.registry
end
@@ -90,21 +90,23 @@
class OpenCensusMonitoringRegistry < BaseMonitoringRegistry
def self.name
'opencensus'
end
- def initialize(project_id, monitored_resource)
+ def initialize(project_id, monitored_resource, gcm_service_address)
super
require 'opencensus'
require 'opencensus-stackdriver'
@log = $log # rubocop:disable Style/GlobalVars
@recorder = OpenCensus::Stats.ensure_recorder
@exporter = OpenCensus::Stats::Exporters::Stackdriver.new(
project_id: project_id,
metric_prefix: 'agent.googleapis.com/agent',
resource_type: monitored_resource.type,
- resource_labels: monitored_resource.labels)
+ resource_labels: monitored_resource.labels,
+ gcm_service_address: gcm_service_address
+ )
OpenCensus.configure do |c|
c.stats.exporter = @exporter
end
@log.debug "OpenCensus config=#{OpenCensus.config}"
end
@@ -146,12 +148,12 @@
def self.supports_monitoring_type(name)
@known_registry_types.key?(name)
end
- def self.create(name, project_id, monitored_resource)
+ def self.create(name, project_id, monitored_resource, gcm_service_address)
registry = @known_registry_types[name] || BaseMonitoringRegistry
- registry.new(project_id, monitored_resource)
+ registry.new(project_id, monitored_resource, gcm_service_address)
end
end
# Translate the internal metrics to the curated metrics in Stackdriver. The
# Prometheus metrics are collected by Google Kubernetes Engine's monitoring,