tracing

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

README

Tracing

There are two main folders in this directory:

  • cloudtrace
  • otel

These are for tracing providers, though Otel is probably all you'll ever need.

Documentation

Overview

Package tracing provides distributed tracing utilities. samber/do: this package's wire.go exposes an empty provider set. No registration helpers are needed here; use observability/tracing/config.RegisterTracerProvider instead.

Index

Constants

This section is empty.

Variables

View Source
var NewNoopTracerProvider = func() TracerProvider {
	return &noopTracerProvider{}
}

NewNoopTracerProvider is a shadow for Otel's NewNoopTracerProvider.

View Source
var (
	PackagePrefix = "github.com/verygoodsoftwarenotvirus/platform/v2/"
)
View Source
var (
	// ProvidersTracing provided HTTP client construction; use httpclient.Providers instead.
	ProvidersTracing = wire.NewSet()
)

Functions

func AttachErrorToSpan

func AttachErrorToSpan(span trace.Span, description string, err error)

AttachErrorToSpan attaches a given error to a span.

func AttachQueryFilterToSpan

func AttachQueryFilterToSpan(span trace.Span, filter *filtering.QueryFilter)

AttachQueryFilterToSpan attaches a given query filter to a span.

func AttachRequestToSpan

func AttachRequestToSpan(span trace.Span, req *http.Request)

AttachRequestToSpan attaches a given HTTP request to a span.

func AttachResponseToSpan

func AttachResponseToSpan(span trace.Span, res *http.Response)

AttachResponseToSpan attaches a given *http.Response to a span.

func AttachSessionContextDataToSpan

func AttachSessionContextDataToSpan(span trace.Span, sessionCtxData SessionContextDataForTracing)

AttachSessionContextDataToSpan provides a consistent way to attach a SessionContextData object to a span.

func AttachToSpan

func AttachToSpan[T any](span trace.Span, attachmentKey string, x T)

func AttachUserAgentDataToSpan

func AttachUserAgentDataToSpan(span trace.Span, req *http.Request)

AttachUserAgentDataToSpan attaches a given search query to a span.

func FormatSpan

func FormatSpan(operation string, req *http.Request) string

FormatSpan formats a span.

func GetCallerName

func GetCallerName() string

GetCallerName is largely (and respectfully) inspired by/copied from https://stackoverflow.com/a/35213181

func NewInstrumentedSQLTracer

func NewInstrumentedSQLTracer(tracerProvider TracerProvider, name string) instrumentedsql.Tracer

NewInstrumentedSQLTracer wraps a Tracer for instrumentedsql.

func StartCustomSpan

func StartCustomSpan(ctx context.Context, name string) (context.Context, trace.Span)

StartCustomSpan starts an anonymous custom span.

func StartSpan

func StartSpan(ctx context.Context) (context.Context, trace.Span)

StartSpan starts an anonymous span. Avoid using PackagePrefix and use an embedded tracer where possible.

Types

type ServicePermissionChecker

type ServicePermissionChecker interface {
	IsServiceAdmin() bool
}

ServicePermissionChecker is a minimal interface for attaching permission state to spans. Export it so the app can adapt authorization.ServiceRolePermissionChecker.

type SessionContextDataForTracing

type SessionContextDataForTracing interface {
	GetUserID() string
	GetServicePermissions() ServicePermissionChecker
	GetActiveAccountID() string
}

SessionContextDataForTracing is a minimal interface for attaching session context to spans. Export it so the app can adapt sessions.ContextData.

type Span

type Span trace.Span

Span is a simple alias for the OpenTelemetry span interface.

type Tracer

type Tracer interface {
	StartSpan(ctx context.Context) (context.Context, Span)
	StartCustomSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, Span)
}

Tracer describes a tracer.

func NewTracer

func NewTracer(t trace.Tracer) Tracer

NewTracer creates a Tracer.

func NewTracerForTest

func NewTracerForTest(name string) Tracer

NewTracerForTest creates a Tracer.

type TracerProvider

type TracerProvider interface {
	trace.TracerProvider
	ForceFlush(context.Context) error
}

TracerProvider is a simple alias for trace.TracerProvider.

func EnsureTracerProvider

func EnsureTracerProvider(tracerProvider TracerProvider) TracerProvider

type User

type User interface {
	GetID() string
	GetUsername() string
}

Directories

Path Synopsis
Package cloudtrace provides common functions for attaching values to trace spans
Package cloudtrace provides common functions for attaching values to trace spans
Package oteltrace provides common functions for attaching values to trace spans
Package oteltrace provides common functions for attaching values to trace spans

Jump to

Keyboard shortcuts

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