iowriter

package module
v0.0.0-...-26f42ef Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

opencensus-go-exporter-iowriter

Overview

This exporter implements both the ExportSpan(sd *trace.SpanData) and ExportView(vd *view.Data) interfaces. By default, it will serialize the data in json format and will write it out to os.Stdout. It can be configured to write out to any io.writer.

The example takes the example code from the opencensus tutorial and demonstrates how to integrate it with this iowriter.

Demo

To see the exporter in action, do the following:

go get github.com/gtrevg/opencensus-go-exporter-iowriter
cd ${GOPATH}/src/github.com/gtrevg/opencensus-go-exporter-iowriter/examples
go get -u
go build
./examples

To-do:

  • Bug - Fix logging of Rows[i].Tags.Key as the value is currently {}
  • Feature - Do not log empty keys in order to reduce log size
  • Feature - Provide option not to log view data description

Documentation

Overview

Package iowriter provides Exporter support for io.Writers for traces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDataKey

func WithDataKey(key string) func(*exporter) error

WithDataKey allows you to override the default "opencensus":{...} key that contains the "SpanData" and "ViewData" opencensus data

func WithKeyValues

func WithKeyValues(m map[string]interface{}) func(*exporter) error

WithKeyValues is a simple way to add additional "baggage" to all trace and metrics logging. A common key value pair to add would be `serviceName` and the name of the service

func WithMessage

func WithMessage(msg string) func(*exporter) error

WithMessage allows you to override the default "msg":"opencensus" log output

func WithWriter

func WithWriter(w io.Writer) func(*exporter) error

WithWriter allows you to set a writer other than the default of os.Stdout

Types

type Exporter

type Exporter interface {
	ExportSpan(sd *trace.SpanData)
	ExportView(vd *view.Data)
}

func New

func New(options ...func(*exporter) error) (Exporter, error)

New creates a new exporter that can used with trace.RegisterExporter() and view.RegisterExporter(). Use the iowriter.With* options to customize additional values

type OpenCensus

type OpenCensus struct {
	SpanData *SpanData `json:",omitempty"`
	ViewData *ViewData `json:",omitempty"`
}

type SpanData

type SpanData struct {
	*trace.SpanData

	// Override a few of the values for cleaner marshalling
	TraceID      string
	SpanID       string
	ParentSpanID string

	// https://github.com/ExpediaDotCom/haystack-idl/blob/master/proto/span.proto#L25
	Duration time.Duration
}

type ViewData

type ViewData struct {
	*view.Data
}

Directories

Path Synopsis
Package main contains a modified version of the code found at:
Package main contains a modified version of the code found at:

Jump to

Keyboard shortcuts

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