monitoring

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package monitoring in testhelpers provides fakers for Tracer and Spans. They can be used in tests to avoid the need for a real tracer. Also, the FakeSpan makes it easy to test the behavior of a Span.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOtelMetricsGrpcServer added in v1.2.0

func NewOtelMetricsGrpcServer(mockServer collector.MetricsServiceServer) (*grpc.Server, []option.ClientOption, error)

Types

type FakeRecordedError

type FakeRecordedError struct {
	Error   error
	Options []oteltrace.EventOption
}

type FakeSpan

type FakeSpan struct {
	oteltrace.Span

	FakeSpanContext *oteltrace.SpanContext

	FakeEvents        []oteltrace.EventOption
	FakeLink          oteltrace.Link
	FakeAttributes    []attribute.KeyValue
	FakeStatus        FakeStatus
	FakeRecordedError FakeRecordedError
}

func GetFakeSpan

func GetFakeSpan(ctx context.Context) (context.Context, FakeSpan)

func (*FakeSpan) AddEvent

func (fs *FakeSpan) AddEvent(name string, options ...oteltrace.EventOption)
func (fs *FakeSpan) AddLink(link oteltrace.Link)

func (*FakeSpan) End

func (fs *FakeSpan) End(options ...oteltrace.SpanEndOption)

func (*FakeSpan) IsRecording

func (fs *FakeSpan) IsRecording() bool

func (*FakeSpan) RecordError

func (fs *FakeSpan) RecordError(err error, options ...oteltrace.EventOption)

func (*FakeSpan) SetAttributes

func (fs *FakeSpan) SetAttributes(kv ...attribute.KeyValue)

func (*FakeSpan) SetStatus

func (fs *FakeSpan) SetStatus(code otelcodes.Code, description string)

func (*FakeSpan) SpanContext

func (fs *FakeSpan) SpanContext() oteltrace.SpanContext

type FakeStatus

type FakeStatus struct {
	Code        otelcodes.Code
	Description string
}

type FakeTracer

type FakeTracer struct {
	oteltrace.Tracer
}

func GetFakeTracer

func GetFakeTracer() (*sdktrace.TracerProvider, FakeTracer)

func (FakeTracer) Start

type MockOtelMetricsServer added in v1.2.0

type MockOtelMetricsServer struct {
	collector.UnimplementedMetricsServiceServer
	// contains filtered or unexported fields
}

func (*MockOtelMetricsServer) Export added in v1.2.0

Jump to

Keyboard shortcuts

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