e2e

package module
v0.0.0-...-20509d8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package e2e provides end-to-end testing utilities for the OpenTelemetry Go Auto instrumentation probes.

Index

Constants

This section is empty.

Variables

View Source
var PortRE = regexp.MustCompile(`^[1-9]\d{1,4}$`)

PortRE is a regular expression that matches valid port numbers.

Functions

func AssertSpanID

func AssertSpanID(t *testing.T, spanID pcommon.SpanID, msgAndArgs ...any) bool

func AssertTraceID

func AssertTraceID(t *testing.T, traceID pcommon.TraceID, msgAndArgs ...any) bool

func AttributesMap

func AttributesMap(attrs pcommon.Map) map[string]pcommon.Value

AttributesMap converts the given attribute map to a native Go map.

func EventByName

func EventByName(span ptrace.Span, name string) (ptrace.SpanEvent, error)

EventByName finds the first event in the span matching the given name.

func LinkByTraceAndSpanID

func LinkByTraceAndSpanID(span ptrace.Span, traceID, spanID string) (ptrace.SpanLink, error)

LinkByTraceAndSpanID locates a link in the span matching the given trace and span ID.

func NewTestLogger

func NewTestLogger(t *testing.T) *slog.Logger

NewTestLogger returns an *slog.Logger that logs to testing.T.

func ResourceAttribute

func ResourceAttribute(td ptrace.Traces, key string) (pcommon.Value, error)

ResourceAttribute returns the value of a specific resource attribute if found.

func ResourceSpans

func ResourceSpans(td ptrace.Traces) []ptrace.ResourceSpans

ResourceSpans returns all resource spans in the given trace data.

func RunInstrumentation

func RunInstrumentation(t *testing.T, mainDir string) ptrace.Traces

RunInstrumentation runs the auto-instrumentation for an end-to-end test. It compiles and runs the target binary located in the mainDir. It then runs the auto-instrumentation targeting the running binary. The traces generated are returned.

The compiled binary is expected to be located in the mainDir directory. It is expected to wait for a SIGCONT signal before starting the main function. The signal is sent to the binary after the auto-instrumentation is loaded, thus ensuring all operations are instrumented correctly.

All setup needed for the correct operation of the binary (i.e. message queues, databases) must be done by the binary itself.

The function is skipped if the memory limit cannot be removed due to insufficient permissions.

func ScopeSpansByName

func ScopeSpansByName(td ptrace.Traces, name string) []ptrace.ScopeSpans

ScopeSpansByName filters scope spans matching the provided scope name.

func SelectSpan

func SelectSpan(
	scopeSpans []ptrace.ScopeSpans,
	selector func(ptrace.Span) bool,
) (ptrace.Span, error)

SelectSpan returns the first span matching the selector from a set of scope spans.

func SpanByName

func SpanByName(scopeSpans []ptrace.ScopeSpans, name string) (ptrace.Span, error)

SpanByName returns the first span with the specified name from a set of scope spans.

func TestIntegration

func TestIntegration(t *testing.T, mainDir string, batsDir string)

Types

This section is empty.

Directories

Path Synopsis
autosdk module
cmd
Package autosdk is a testing application for the go.opentelemetry.io/auto/sdk package.
Package autosdk is a testing application for the go.opentelemetry.io/auto/sdk package.
databasesql module
cmd
Package databasesql is a testing application for the database/sql package.
Package databasesql is a testing application for the database/sql package.
gin module
cmd
Package gin is a testing application for the github.com/gin-gonic/gin package.
Package gin is a testing application for the github.com/gin-gonic/gin package.
gorillamux module
grpc module
cmd
Package grpc is a testing application for the google.golang.org/grpc package.
Package grpc is a testing application for the google.golang.org/grpc package.
kafka-go module
cmd
Package kafka-go is a testing application for the github.com/segmentio/kafka-go package.
Package kafka-go is a testing application for the github.com/segmentio/kafka-go package.
nethttp module
cmd
Package nethttp is a testing application for the net/http package.
Package nethttp is a testing application for the net/http package.
nethttp_custom
cmd
Package nethttp_custom is a testing application for the net/http package.
Package nethttp_custom is a testing application for the net/http package.
nonrecording
cmd
Package nonrecording is a testing application for the go.opentelemetry.io/otel/trace package.
Package nonrecording is a testing application for the go.opentelemetry.io/otel/trace package.
otelglobal module
cmd
Package otelglobal is a testing application for the go.opentelemetry.io/otel package.
Package otelglobal is a testing application for the go.opentelemetry.io/otel package.

Jump to

Keyboard shortcuts

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