package tracing

import "github.com/docker/compose/v2/internal/tracing"

Index

Functions

func AddAttributeToSpan

func AddAttributeToSpan(ctx context.Context, attr ...attribute.KeyValue)

func EventWrapFuncForErrGroup

func EventWrapFuncForErrGroup(ctx context.Context, eventName string, opts SpanOptions, fn func(ctx context.Context) error) func() error

EventWrapFuncForErrGroup invokes a function and records an event, optionally including the returned error as the "exception message" on the event.

This is intended for lightweight usage to wrap errgroup.Group calls where a full span is not desired.

func KeyboardMetrics

func KeyboardMetrics(ctx context.Context, enabled, isDockerDesktopActive, isWatchConfigured bool)

func SpanWrapFunc

func SpanWrapFunc(spanName string, opts SpanOptions, fn func(ctx context.Context) error) func(context.Context) error

SpanWrapFunc wraps a function that takes a context with a trace.Span, marking the status as codes.Error if the wrapped function returns an error.

The context passed to the function is created from the span to ensure correct propagation.

NOTE: This function is nearly identical to SpanWrapFuncForErrGroup, except the latter is designed specially for convenience with errgroup.Group due to its prevalence throughout the codebase. The code is duplicated to avoid adding even more levels of function wrapping/indirection.

func SpanWrapFuncForErrGroup

func SpanWrapFuncForErrGroup(ctx context.Context, spanName string, opts SpanOptions, fn func(ctx context.Context) error) func() error

SpanWrapFuncForErrGroup wraps a function that takes a context with a trace.Span, marking the status as codes.Error if the wrapped function returns an error.

The context passed to the function is created from the span to ensure correct propagation.

NOTE: This function is nearly identical to SpanWrapFunc, except this function is designed specially for convenience with errgroup.Group due to its prevalence throughout the codebase. The code is duplicated to avoid adding even more levels of function wrapping/indirection.

Types

type Metrics

type Metrics struct {
	CountExtends        int
	CountIncludesLocal  int
	CountIncludesRemote int
}

type MetricsKey

type MetricsKey struct{}

type MuxExporter

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

func (MuxExporter) ExportSpans

func (m MuxExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (MuxExporter) Shutdown

func (m MuxExporter) Shutdown(ctx context.Context) error

type OTLPConfig

type OTLPConfig struct {
	Endpoint string
}

OTLPConfig contains the necessary values to initialize an OTLP client manually.

This supports a minimal set of options based on what is necessary for automatic OTEL configuration from Docker context metadata.

func ConfigFromDockerContext

func ConfigFromDockerContext(st store.Store, name string) (OTLPConfig, error)

ConfigFromDockerContext inspects extra metadata included as part of the specified Docker context to try and extract a valid OTLP client configuration.

type ShutdownFunc

type ShutdownFunc func(ctx context.Context) error

ShutdownFunc flushes and stops an OTEL exporter.

func InitProvider

func InitProvider(dockerCli command.Cli) (ShutdownFunc, error)

func InitTracing

func InitTracing(dockerCli command.Cli) (ShutdownFunc, error)

type SpanOptions

type SpanOptions []trace.SpanStartEventOption

SpanOptions is a small helper type to make it easy to share the options helpers between downstream functions that accept slices of trace.SpanStartOption and trace.EventOption.

func ContainerOptions

func ContainerOptions(ctr container.Summary) SpanOptions

ContainerOptions returns common attributes from a Moby container.

For convenience, it's returned as a SpanOptions object to allow it to be passed directly to the wrapping helper methods in this package such as SpanWrapFunc.

func ProjectOptions

func ProjectOptions(ctx context.Context, proj *types.Project) SpanOptions

ProjectOptions returns common attributes from a Compose project.

For convenience, it's returned as a SpanOptions object to allow it to be passed directly to the wrapping helper methods in this package such as SpanWrapFunc.

func ServiceOptions

func ServiceOptions(service types.ServiceConfig) SpanOptions

ServiceOptions returns common attributes from a Compose service.

For convenience, it's returned as a SpanOptions object to allow it to be passed directly to the wrapping helper methods in this package such as SpanWrapFunc.

func (SpanOptions) EventOptions

func (s SpanOptions) EventOptions() []trace.EventOption

func (SpanOptions) SpanStartOptions

func (s SpanOptions) SpanStartOptions() []trace.SpanStartOption

Source Files

attributes.go docker_context.go errors.go keyboard_metrics.go mux.go tracing.go wrap.go

Version
v2.35.1 (latest)
Published
Apr 17, 2025
Platform
linux/amd64
Imports
31 packages
Last checked
7 hours ago

Tools for package owners.