Class: OpenCensus::Trace::Exporters::Logger

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

Overview

The Logger exporter exports captured spans 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.



35
36
37
38
# File 'lib/opencensus/trace/exporters/logger.rb', line 35

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

Instance Method Details

#export(spans) ⇒ Object

Export the captured spans to the configured logger.

Parameters:

  • spans (Array<Span>)

    The captured spans.



45
46
47
48
# File 'lib/opencensus/trace/exporters/logger.rb', line 45

def export spans
  @logger.log @level, spans.map { |span| format_span(span) }.to_json
  nil
end