oteltest

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package oteltest provides functionalities for testing otelsql.

Index

Constants

This section is empty.

Variables

View Source
var NilSpanID trace.SpanID

NilSpanID is an empty span id.

View Source
var NilTraceID trace.TraceID

NilTraceID is an empty trace id.

View Source
var SampleSpanID = MustParseSpanID("1d256548fd1a0dba")

SampleSpanID is a sample of span id.

View Source
var SampleTraceID = MustParseTraceID("25239e8a2ad5562d561f2ecd6a9744de")

SampleTraceID is a sample of trace id.

Functions

func BackgroundWithSpanContext

func BackgroundWithSpanContext(traceID trace.TraceID, spanID trace.SpanID) context.Context

BackgroundWithSpanContext creates a new context.Background with trace id and span id.

func MustParseSpanID

func MustParseSpanID(s string) trace.SpanID

MustParseSpanID parse a string to span id.

func MustParseTraceID

func MustParseTraceID(s string) trace.TraceID

MustParseTraceID parse a string to trace id.

Types

type Span

type Span struct {
	Name        string          `json:"Name"`
	SpanContext SpanContext     `json:"SpanContext"`
	Parent      SpanContext     `json:"Parent"`
	SpanKind    int             `json:"SpanKind"`
	Attributes  []SpanAttribute `json:"Attributes"`
}

Span represents a span.

type SpanAttribute

type SpanAttribute struct {
	Key   string `json:"Key"`
	Value struct {
		Type  string      `json:"Type"`
		Value interface{} `json:"Value"`
	} `json:"Value"`
}

SpanAttribute represents a span attribute.

type SpanContext

type SpanContext struct {
	TraceID string `json:"TraceID"`
	SpanID  string `json:"SpanID"`
}

SpanContext represents a span context.

type Suite

type Suite interface {
	Run(t *testing.T, f func(sc SuiteContext))
}

Suite is a test suite.

func New

func New(opts ...SuiteOption) Suite

New creates a new test suite.

type SuiteContext

type SuiteContext interface {
	TracerProvider() trace.TracerProvider
	MeterProvider() metric.MeterProvider
	DatabaseDSN() string
}

SuiteContext represents a test suite context.

type SuiteOption

type SuiteOption func(c *suiteConfig)

SuiteOption setups the test suite.

func MetricsEmpty

func MetricsEmpty() SuiteOption

MetricsEmpty sets metrics asserter.

func MetricsEqualJSON

func MetricsEqualJSON(expect string) SuiteOption

MetricsEqualJSON sets metrics asserter.

func MockDatabase

func MockDatabase(mocks ...func(m sqlmock.Sqlmock)) SuiteOption

MockDatabase sets sql mockers.

func TracesEmpty

func TracesEmpty() SuiteOption

TracesEmpty sets traces asserter.

func TracesEqualJSON

func TracesEqualJSON(expect string) SuiteOption

TracesEqualJSON sets traces asserter.

func TracesMatch

func TracesMatch(f func(t assert.TestingT, actual []Span) bool) SuiteOption

TracesMatch asserts traces by a callback.

func WithMetricsAsserters

func WithMetricsAsserters(fs ...testassert.Func) SuiteOption

WithMetricsAsserters sets metrics asserter.

func WithTracesAsserters

func WithTracesAsserters(fs ...testassert.Func) SuiteOption

WithTracesAsserters sets traces asserter.

Jump to

Keyboard shortcuts

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