otel: go.opentelemetry.io/otel/internal/trace Index | Files | Directories

package trace

import "go.opentelemetry.io/otel/internal/trace"

Index

Package Files

mock_span.go mock_tracer.go

type MockSpan Uses

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

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

func (*MockSpan) AddEvent Uses

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

AddEvent does nothing.

func (*MockSpan) AddEventWithTimestamp Uses

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

AddEvent does nothing.

func (*MockSpan) End Uses

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

End does nothing.

func (*MockSpan) IsRecording Uses

func (ms *MockSpan) IsRecording() bool

IsRecording always returns false for MockSpan.

func (*MockSpan) SetAttributes Uses

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

SetAttributes does nothing.

func (*MockSpan) SetError Uses

func (ms *MockSpan) SetError(v bool)

SetError does nothing.

func (*MockSpan) SetName Uses

func (ms *MockSpan) SetName(name string)

SetName does nothing.

func (*MockSpan) SetStatus Uses

func (ms *MockSpan) SetStatus(status codes.Code)

SetStatus does nothing.

func (*MockSpan) SpanContext Uses

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

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

func (*MockSpan) Tracer Uses

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

Tracer returns MockTracer implementation of Tracer.

type MockTracer Uses

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
}

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 Uses

func (mt *MockTracer) Start(ctx context.Context, name string, o ...apitrace.StartOption) (context.Context, apitrace.Span)

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 Uses

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

PathSynopsis
parent

Package trace imports 9 packages (graph). Updated 2020-02-22. Refresh now. Tools for package owners.