Package exporter contains a log exporter that supports exporting OpenCensus metrics and spans to a logging framework.



This section is empty.


This section is empty.


This section is empty.


type LogExporter

type LogExporter struct {
	// contains filtered or unexported fields

LogExporter exports metrics and span to log file

func NewLogExporter

func NewLogExporter(options Options) (*LogExporter, error)

NewLogExporter creates new log exporter.

func (*LogExporter) Close

func (e *LogExporter) Close()

Close closes any files that were opened for logging.

func (*LogExporter) ExportMetrics

func (e *LogExporter) ExportMetrics(ctx context.Context, metrics []*metricdata.Metric) error

ExportMetrics exports to log.

func (*LogExporter) ExportSpan

func (e *LogExporter) ExportSpan(sd *trace.SpanData)

ExportSpan exports a SpanData to log

func (*LogExporter) Start

func (e *LogExporter) Start() error

Start starts the metric and span data exporter.

func (*LogExporter) Stop

func (e *LogExporter) Stop()

Stop stops the metric and span data exporter.

type Options

type Options struct {
	// ReportingInterval is a time interval between two successive metrics
	// export.
	ReportingInterval time.Duration

	// MetricsLogFile is path where exported metrics are logged.
	// If it is nil then the metrics are logged on console
	MetricsLogFile string

	// TracesLogFile is path where exported span data are logged.
	// If it is nil then the span data are logged on console
	TracesLogFile string

Options provides options for LogExporter

type PrintExporter

type PrintExporter struct{}

PrintExporter is a stats and trace exporter that logs the exported data to the console.

The intent is help new users familiarize themselves with the capabilities of opencensus.

This should NOT be used for production workloads.

func (*PrintExporter) ExportSpan

func (e *PrintExporter) ExportSpan(vd *trace.SpanData)

ExportSpan logs the trace span.

func (*PrintExporter) ExportView

func (e *PrintExporter) ExportView(vd *view.Data)

ExportView logs the view data.