...

Package metricexport

import "go.opencensus.io/metric/metricexport"
Overview
Index

Overview ▾

Package metricexport contains support for exporting metric data.

This is an EXPERIMENTAL package, and may change in arbitrary ways without notice.

type Exporter

Exporter is an interface that exporters implement to export the metric data.

type Exporter interface {
    ExportMetrics(ctx context.Context, data []*metricdata.Metric) error
}

type IntervalReader

IntervalReader periodically reads metrics from all producers registered with producer manager and exports those metrics using provided exporter. Call Reader.Stop() to stop the reader.

type IntervalReader struct {
    // ReportingInterval it the time duration between two consecutive
    // metrics reporting. defaultReportingDuration  is used if it is not set.
    // It cannot be set lower than minimumReportingDuration.
    ReportingInterval time.Duration
    // contains filtered or unexported fields
}

func NewIntervalReader

func NewIntervalReader(reader *Reader, exporter Exporter) (*IntervalReader, error)

NewIntervalReader creates a reader. Once started it periodically reads metrics from all producers and exports them using provided exporter.

func (*IntervalReader) Flush

func (ir *IntervalReader) Flush()

Flush flushes the metrics if IntervalReader is stopped, otherwise no-op.

func (*IntervalReader) Start

func (ir *IntervalReader) Start() error

Start starts the IntervalReader which periodically reads metrics from all producers registered with global producer manager. If the reporting interval is not set prior to calling this function then default reporting interval is used.

func (*IntervalReader) Stop

func (ir *IntervalReader) Stop()

Stop stops the reader from reading and exporting metrics. Additional call to Stop are no-ops.

type Reader

Reader reads metrics from all producers registered with producer manager and exports those metrics using provided exporter.

type Reader struct {
    // contains filtered or unexported fields
}

func NewReader

func NewReader(o ...ReaderOption) *Reader

NewReader returns a reader configured with specified options.

func (*Reader) ReadAndExport

func (r *Reader) ReadAndExport(exporter Exporter)

ReadAndExport reads metrics from all producer registered with producer manager and then exports them using provided exporter.

type ReaderOption

ReaderOption apply changes to ReaderOptions.

type ReaderOption func(*ReaderOptions)

func WithSpanName

func WithSpanName(spanName string) ReaderOption

WithSpanName makes new reader to use given span name when exporting metrics.

type ReaderOptions

ReaderOptions contains options pertaining to metrics reader.

type ReaderOptions struct {
    // SpanName is the name used for span created to export metrics.
    SpanName string
}