octest

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package octest supports testing of OpenCensus integrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(gotSpans []*trace.SpanData, gotRows []*view.Row, namePrefix, provider string, want []Call) string

Diff compares the list of spans and metric counts obtained from OpenCensus instrumentation (using the TestExporter in this package, or similar) with an expected list of calls. Only the name and code are compared. Order matters for traces (though not for metrics).

Types

type Call

type Call struct {
	Method string
	Code   gdkerr.ErrorCode
}

Call holds the expected contents of a measured call. It is used for both metric and trace comparison.

type TestExporter

type TestExporter struct {
	Stats chan *view.Data
	// contains filtered or unexported fields
}

TestExporter is an exporter of OpenCensus traces and metrics, for testing. It should be created with NewTestExporter.

func NewTestExporter

func NewTestExporter(views []*view.View) *TestExporter

NewTestExporter creates a TestExporter and registers it with OpenCensus.

func (*TestExporter) Counts

func (te *TestExporter) Counts() []*view.Row

Counts returns the first exported data that includes aggregated counts.

func (*TestExporter) ExportSpan

func (te *TestExporter) ExportSpan(s *trace.SpanData)

ExportSpan "exports" a span by remembering it.

func (*TestExporter) ExportView

func (te *TestExporter) ExportView(vd *view.Data)

ExportView exports a view by writing it to the Stats channel.

func (*TestExporter) Spans

func (te *TestExporter) Spans() []*trace.SpanData

Spans returns the exporter's traces.

func (*TestExporter) Unregister

func (te *TestExporter) Unregister()

Unregister unregisters the exporter from OpenCensus.

Jump to

Keyboard shortcuts

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