Exporter is an interface that exporters implement to export the metric data.
type Exporter interface { ExportMetrics(ctx context.Context, data []*metricdata.Metric) error }
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(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 (ir *IntervalReader) Flush()
Flush flushes the metrics if IntervalReader is stopped, otherwise no-op.
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 (ir *IntervalReader) Stop()
Stop stops the reader from reading and exporting metrics. Additional call to Stop are no-ops.
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(o ...ReaderOption) *Reader
NewReader returns a reader configured with specified options.
func (r *Reader) ReadAndExport(exporter Exporter)
ReadAndExport reads metrics from all producer registered with producer manager and then exports them using provided exporter.
ReaderOption apply changes to ReaderOptions.
type ReaderOption func(*ReaderOptions)
func WithSpanName(spanName string) ReaderOption
WithSpanName makes new reader to use given span name when exporting metrics.
ReaderOptions contains options pertaining to metrics reader.
type ReaderOptions struct { // SpanName is the name used for span created to export metrics. SpanName string }