Class: OpenCensus::Stats::Exporters::Logger

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

Overview

The Logger exporter exports captured stats view data to a standard Ruby Logger interface.

Instance Method Summary collapse

Constructor Details

#initialize(logger, level: ::Logger::INFO) ⇒ Logger

Create a new Logger exporter

Parameters:

  • logger (#log)

    The logger to write to.

  • level (Integer) (defaults to: ::Logger::INFO)

    The log level. This should be a log level defined by the Logger standard library. Default is ::Logger::INFO.



23
24
25
26
# File 'lib/opencensus/stats/exporters/logger.rb', line 23

def initialize logger, level: ::Logger::INFO
  @logger = logger
  @level = level
end

Instance Method Details

#export(views_data) ⇒ Object

Export the captured stats to the configured logger.

Parameters:

  • views_data (Array<ViewData>)

    The captured stats data.



33
34
35
36
37
# File 'lib/opencensus/stats/exporters/logger.rb', line 33

def export views_data
  stats_data = views_data.map { |vd| format_view_data(vd) }
  @logger.log @level, stats_data.to_json
  nil
end