Class: OpenCensus::Stats::Exporters::Multi

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/opencensus/stats/exporters/multi.rb

Overview

The Multi exporter multiplexes captured stats to a set of delegate exporters. It is useful if you need to export to more than one destination. You may also use it as a “null” exporter by providing no delegates.

Multi delegates to an array of the exporter objects. You can manage the list of exporters using any method of Array. For example:

multi = OpenCensus::Stats::Exporters::Multi.new
multi.export(views_data)  # Does nothing
multi << OpenCensus::Stats::Exporters::Logger.new
multi.export(views_data)  # Exports to the logger

Instance Method Summary collapse

Constructor Details

#initialize(*delegates) ⇒ Multi

Create a new Multi exporter

Parameters:

  • delegates (Array<#export>)

    An array of exporters



41
42
43
# File 'lib/opencensus/stats/exporters/multi.rb', line 41

def initialize *delegates
  super(delegates.flatten)
end

Instance Method Details

#export(views_data) ⇒ Object

Pass the captured stats view data to the delegates.

Parameters:

  • views_data (Array<ViewData>)

    The captured stats.



50
51
52
53
# File 'lib/opencensus/stats/exporters/multi.rb', line 50

def export views_data
  each { |delegate| delegate.export views_data }
  nil
end