...

Package internaltest

import "go.opentelemetry.io/otel/internal/internaltest"
Overview
Index

Overview ▾

Index ▾

func Aligned8Byte(fields []FieldOffset, out io.Writer) bool
func NewTestError(s string) error
type Env
type EnvStore
    func NewEnvStore() EnvStore
    func SetEnvVariables(env map[string]string) (EnvStore, error)
type FieldOffset
type Harness
    func NewHarness(t *testing.T) *Harness
    func (h *Harness) TestTracer(subjectFactory func() trace.Tracer)
    func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)
type TestError
    func (e TestError) Error() string
type TextMapCarrier
    func NewTextMapCarrier(data map[string]string) *TextMapCarrier
    func (c *TextMapCarrier) Get(key string) string
    func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool
    func (c *TextMapCarrier) GotN(t *testing.T, n int) bool
    func (c *TextMapCarrier) Keys() []string
    func (c *TextMapCarrier) Reset(data map[string]string)
    func (c *TextMapCarrier) Set(key, value string)
    func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool
    func (c *TextMapCarrier) SetN(t *testing.T, n int) bool
type TextMapPropagator
    func NewTextMapPropagator(name string) *TextMapPropagator
    func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
    func (p *TextMapPropagator) ExtractedN(t *testing.T, ctx context.Context, n int) bool
    func (p *TextMapPropagator) Fields() []string
    func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
    func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool

Package files

alignment.go env.go errors.go harness.go text_map_carrier.go text_map_propagator.go

func Aligned8Byte

func Aligned8Byte(fields []FieldOffset, out io.Writer) bool

Aligned8Byte returns if all fields are aligned modulo 8-bytes.

Error messaging is printed to out for any field determined misaligned.

func NewTestError

func NewTestError(s string) error

type Env

type Env struct {
    Name   string
    Value  string
    Exists bool
}

type EnvStore

EnvStore stores and recovers environment variables.

type EnvStore interface {
    // Records the environment variable into the store.
    Record(key string)

    // Restore recovers the environment variables in the store.
    Restore() error
}

func NewEnvStore

func NewEnvStore() EnvStore

func SetEnvVariables

func SetEnvVariables(env map[string]string) (EnvStore, error)

type FieldOffset

FieldOffset is a preprocessor representation of a struct field alignment.

type FieldOffset struct {
    // Name of the field.
    Name string

    // Offset of the field in bytes.
    //
    // To compute this at compile time use unsafe.Offsetof.
    Offset uintptr
}

type Harness

Harness is a testing harness used to test implementations of the OpenTelemetry API.

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

func NewHarness

func NewHarness(t *testing.T) *Harness

NewHarness returns an instantiated *Harness using t.

func (*Harness) TestTracer

func (h *Harness) TestTracer(subjectFactory func() trace.Tracer)

TestTracer runs validation tests for an implementation of the OpenTelemetry Tracer API.

func (*Harness) TestTracerProvider

func (h *Harness) TestTracerProvider(subjectFactory func() trace.TracerProvider)

TestTracerProvider runs validation tests for an implementation of the OpenTelemetry TracerProvider API.

type TestError

type TestError string

func (TestError) Error

func (e TestError) Error() string

type TextMapCarrier

TextMapCarrier is a storage medium for a TextMapPropagator used in testing. The methods of a TextMapCarrier are concurrent safe.

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

func NewTextMapCarrier

func NewTextMapCarrier(data map[string]string) *TextMapCarrier

NewTextMapCarrier returns a new *TextMapCarrier populated with data.

func (*TextMapCarrier) Get

func (c *TextMapCarrier) Get(key string) string

Get returns the value associated with the passed key.

func (*TextMapCarrier) GotKey

func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool

GotKey tests if c.Get has been called for key.

func (*TextMapCarrier) GotN

func (c *TextMapCarrier) GotN(t *testing.T, n int) bool

GotN tests if n calls to c.Get have been made.

func (*TextMapCarrier) Keys

func (c *TextMapCarrier) Keys() []string

Keys returns the keys for which this carrier has a value.

func (*TextMapCarrier) Reset

func (c *TextMapCarrier) Reset(data map[string]string)

Reset zeros out the recording state and sets the carried values to data.

func (*TextMapCarrier) Set

func (c *TextMapCarrier) Set(key, value string)

Set stores the key-value pair.

func (*TextMapCarrier) SetKeyValue

func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool

SetKeyValue tests if c.Set has been called for the key-value pair.

func (*TextMapCarrier) SetN

func (c *TextMapCarrier) SetN(t *testing.T, n int) bool

SetN tests if n calls to c.Set have been made.

type TextMapPropagator

TextMapPropagator is a propagation.TextMapPropagator used for testing.

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

func NewTextMapPropagator

func NewTextMapPropagator(name string) *TextMapPropagator

NewTextMapPropagator returns a new TextMapPropagator for testing. It will use name as the key it injects into a TextMapCarrier when Inject is called.

func (*TextMapPropagator) Extract

func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context

Extract reads cross-cutting concerns for p from carrier into ctx.

func (*TextMapPropagator) ExtractedN

func (p *TextMapPropagator) ExtractedN(t *testing.T, ctx context.Context, n int) bool

ExtractedN tests if p has made n extractions from the lineage of ctx. nolint (context is not first arg)

func (*TextMapPropagator) Fields

func (p *TextMapPropagator) Fields() []string

Fields returns the name of p as the key who's value is set with Inject.

func (*TextMapPropagator) Inject

func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)

Inject sets cross-cutting concerns for p from ctx into carrier.

func (*TextMapPropagator) InjectedN

func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool

InjectedN tests if p has made n injections to carrier.