Package stdout contains an OpenTelemetry exporter for both tracing and metric telemetry to be written to an output destination as JSON.

    This package is currently in a pre-GA phase. Backwards incompatible changes may be introduced in subsequent minor version releases as we work to track the evolving OpenTelemetry specification and user feedback.





    This section is empty.


    This section is empty.


    func InstallNewPipeline

    func InstallNewPipeline(exportOpts []Option, pushOpts []controller.Option) (*controller.Controller, error)

      InstallNewPipeline creates a complete export pipelines with defaults and registers it globally. It is the responsibility of the caller to stop the returned push Controller.

      Typically this is called as:

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

      func NewExportPipeline

      func NewExportPipeline(exportOpts []Option, pushOpts []controller.Option) (trace.TracerProvider, *controller.Controller, error)

        NewExportPipeline creates a complete export pipeline with the default selectors, processors, and trace registration. It is the responsibility of the caller to stop the returned push Controller.


        type Config

        type Config struct {
        	// Writer is the destination.  If not set, os.Stdout is used.
        	Writer io.Writer
        	// PrettyPrint will encode the output into readable JSON. Default is
        	// false.
        	PrettyPrint bool
        	// Timestamps specifies if timestamps should be pritted. Default is
        	// true.
        	Timestamps bool
        	// LabelEncoder encodes the labels.
        	LabelEncoder attribute.Encoder
        	// DisableTraceExport prevents any export of trace telemetry.
        	DisableTraceExport bool
        	// DisableMetricExport prevents any export of metric telemetry.
        	DisableMetricExport bool

          Config contains options for the STDOUT exporter.

          func NewConfig

          func NewConfig(options ...Option) (Config, error)

            NewConfig creates a validated Config configured with options.

            type Exporter

            type Exporter struct {
            	// contains filtered or unexported fields

            func NewExporter

            func NewExporter(options ...Option) (*Exporter, error)

              NewExporter creates an Exporter with the passed options.

              func (*Exporter) Export

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

              func (*Exporter) ExportKindFor

              func (e *Exporter) ExportKindFor(desc *metric.Descriptor, kind aggregation.Kind) exportmetric.ExportKind

              func (*Exporter) ExportSpans

              func (e *Exporter) ExportSpans(ctx context.Context, ss []*trace.SpanSnapshot) error

                ExportSpans writes SpanSnapshots in json format to stdout.

                func (*Exporter) Shutdown

                func (e *Exporter) Shutdown(ctx context.Context) error

                  Shutdown is called to stop the exporter, it preforms no action.

                  type Option

                  type Option interface {
                  	// Apply option value to Config.
                  	// contains filtered or unexported methods

                    Option sets the value of an option for a Config.

                    func WithLabelEncoder

                    func WithLabelEncoder(enc attribute.Encoder) Option

                      WithLabelEncoder sets the label encoder used in export.

                      func WithPrettyPrint

                      func WithPrettyPrint() Option

                        WithPrettyPrint sets the export stream format to use JSON.

                        func WithWriter

                        func WithWriter(w io.Writer) Option

                          WithWriter sets the export stream destination.

                          func WithoutMetricExport

                          func WithoutMetricExport() Option

                            WithoutMetricExport disables all metric exporting.

                            func WithoutTimestamps

                            func WithoutTimestamps() Option

                              WithoutTimestamps sets the export stream to not include timestamps.

                              func WithoutTraceExport

                              func WithoutTraceExport() Option

                                WithoutTraceExport disables all trace exporting.