stdout

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallNewPipeline

func InstallNewPipeline(config Config, options ...push.Option) (*push.Controller, error)

InstallNewPipeline instantiates a NewExportPipeline and registers it globally. Typically called as:

pipeline, err := stdout.InstallNewPipeline(stdout.Config{...})
if err != nil {
	...
}
defer pipeline.Stop()
... Done

func NewExportPipeline

func NewExportPipeline(config Config, options ...push.Option) (*push.Controller, error)

NewExportPipeline sets up a complete export pipeline with the recommended setup, chaining a NewRawExporter into the recommended selectors and processors.

Example
package main

import (
	"context"
	"log"

	"go.opentelemetry.io/otel/api/kv"
	"go.opentelemetry.io/otel/api/metric"
	"go.opentelemetry.io/otel/exporters/metric/stdout"
)

func main() {
	// Create a meter
	pusher, err := stdout.NewExportPipeline(stdout.Config{
		PrettyPrint:    true,
		DoNotPrintTime: true,
	})
	if err != nil {
		log.Fatal("Could not initialize stdout exporter:", err)
	}
	defer pusher.Stop()

	ctx := context.Background()

	key := kv.Key("key")
	meter := pusher.Provider().Meter(
		"github.com/instrumentron",
		metric.WithInstrumentationVersion("v0.1.0"),
	)

	// Create and update a single counter:
	counter := metric.Must(meter).NewInt64Counter("a.counter")
	labels := []kv.KeyValue{key.String("value")}

	counter.Add(ctx, 100, labels...)

}
Output:

{
	"updates": [
		{
			"name": "a.counter{instrumentation.name=github.com/instrumentron,instrumentation.version=v0.1.0,key=value}",
			"sum": 100
		}
	]
}

Types

type Config

type Config struct {
	// Writer is the destination.  If not set, os.Stdout is used.
	Writer io.Writer

	// PrettyPrint will pretty the json representation of the span,
	// making it print "pretty". Default is false.
	PrettyPrint bool

	// DoNotPrintTime suppresses timestamp printing.  This is
	// useful to create deterministic test conditions.
	DoNotPrintTime bool

	// Quantiles are the desired aggregation quantiles for distribution
	// summaries, used when the configured aggregator supports
	// quantiles.
	//
	// Note: this exporter is meant as a demonstration; a real
	// exporter may wish to configure quantiles on a per-metric
	// basis.
	Quantiles []float64

	// LabelEncoder encodes the labels
	LabelEncoder label.Encoder
}

Config is the configuration to be used when initializing a stdout export.

type Exporter

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

func NewRawExporter

func NewRawExporter(config Config) (*Exporter, error)

NewRawExporter creates a stdout Exporter for use in a pipeline.

func (*Exporter) Export

func (e *Exporter) Export(_ context.Context, checkpointSet export.CheckpointSet) error

func (*Exporter) ExportKindFor added in v0.7.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL