trace

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockSpan

type MockSpan struct {
	Name string
	// contains filtered or unexported fields
}

MockSpan is a mock span used in association with MockTracer for testing purpose only.

func (*MockSpan) AddEvent

func (ms *MockSpan) AddEvent(ctx context.Context, name string, attrs ...kv.KeyValue)

AddEvent does nothing.

func (*MockSpan) AddEventWithTimestamp

func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...kv.KeyValue)

AddEvent does nothing.

func (*MockSpan) End

func (ms *MockSpan) End(options ...apitrace.EndOption)

End does nothing.

func (*MockSpan) IsRecording

func (ms *MockSpan) IsRecording() bool

IsRecording always returns false for MockSpan.

func (*MockSpan) RecordError added in v0.2.3

func (ms *MockSpan) RecordError(ctx context.Context, err error, opts ...apitrace.ErrorOption)

RecordError does nothing.

func (*MockSpan) SetAttribute

func (ms *MockSpan) SetAttribute(k string, v interface{})

SetAttribute does nothing.

func (*MockSpan) SetAttributes

func (ms *MockSpan) SetAttributes(attributes ...kv.KeyValue)

SetAttributes does nothing.

func (*MockSpan) SetError

func (ms *MockSpan) SetError(v bool)

SetError does nothing.

func (*MockSpan) SetName

func (ms *MockSpan) SetName(name string)

SetName sets the span name.

func (*MockSpan) SetStatus

func (ms *MockSpan) SetStatus(status codes.Code, msg string)

SetStatus does nothing.

func (*MockSpan) SpanContext

func (ms *MockSpan) SpanContext() apitrace.SpanContext

SpanContext returns associated kv.SpanContext. If the receiver is nil it returns an empty kv.SpanContext

func (*MockSpan) Tracer

func (ms *MockSpan) Tracer() apitrace.Tracer

Tracer returns MockTracer implementation of Tracer.

type MockTracer

type MockTracer struct {
	// StartSpanID is used to initialize spanId. It is incremented by one
	// every time a new span is created.
	//
	// StartSpanID has to be aligned for 64-bit atomic operations.
	StartSpanID *uint64

	// Sampled specifies if the new span should be sampled or not.
	Sampled bool

	// OnSpanStarted is called every time a new trace span is started
	OnSpanStarted func(span *MockSpan)
}

MockTracer is a simple tracer used for testing purpose only. It only supports ChildOf option. SpanId is atomically increased every time a new span is created.

func (*MockTracer) Start

Start starts a MockSpan. It creates a new Span based on Parent SpanContext option. TracdID is used from Parent Span Context and SpanID is assigned. If Parent SpanContext option is not specified then random TraceID is used. No other options are supported.

func (*MockTracer) WithSpan

func (mt *MockTracer) WithSpan(ctx context.Context, name string, body func(context.Context) error, opts ...apitrace.StartOption) error

WithSpan does nothing except executing the body.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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