tracing

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

func ContextWithSpan(ctx context.Context, span trace.Span) context.Context

ContextWithSpan wraps trace.ContextWithSpan for convenience.

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext returns the current span from context, useful for adding attributes from within workflow handlers.

func SpanMiddleware

func SpanMiddleware(next http.Handler) http.Handler

SpanMiddleware returns HTTP middleware that creates a span for each request and propagates trace context from incoming headers.

Types

type Config

type Config struct {
	// Endpoint is the OTLP HTTP endpoint (e.g., "localhost:4318").
	Endpoint string
	// ServiceName is the service name reported in traces.
	ServiceName string
	// ServiceVersion is the optional service version.
	ServiceVersion string
	// Insecure disables TLS for the OTLP exporter.
	Insecure bool
	// SampleRate controls the trace sampling ratio (0.0 to 1.0). 0 means default (always sample).
	SampleRate float64
}

Config holds configuration for the TracerProvider setup.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Provider

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

Provider wraps an OpenTelemetry TracerProvider and handles lifecycle.

func NewProvider

func NewProvider(ctx context.Context, cfg Config) (*Provider, error)

NewProvider creates a new TracerProvider from the given config and sets it as the global provider.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the tracer provider, flushing pending spans.

func (*Provider) Tracer

func (p *Provider) Tracer() trace.Tracer

Tracer returns the named tracer from the provider.

func (*Provider) TracerProvider

func (p *Provider) TracerProvider() *sdktrace.TracerProvider

TracerProvider returns the underlying SDK TracerProvider.

type WorkflowTracer

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

WorkflowTracer provides convenience methods for creating spans around workflow execution lifecycle events.

func NewWorkflowTracer

func NewWorkflowTracer(tracer trace.Tracer) *WorkflowTracer

NewWorkflowTracer creates a WorkflowTracer. If tracer is nil, the global tracer provider is used.

func (*WorkflowTracer) RecordError

func (w *WorkflowTracer) RecordError(span trace.Span, err error)

RecordError records an error on the given span and sets the span status.

func (*WorkflowTracer) SetSuccess

func (w *WorkflowTracer) SetSuccess(span trace.Span)

SetSuccess marks a span as successful.

func (*WorkflowTracer) StartStep

func (w *WorkflowTracer) StartStep(ctx context.Context, stepName, stepType string) (context.Context, trace.Span)

StartStep begins a child span for a workflow step.

func (*WorkflowTracer) StartTrigger

func (w *WorkflowTracer) StartTrigger(ctx context.Context, triggerName, triggerType string) (context.Context, trace.Span)

StartTrigger begins a span for a trigger invocation.

func (*WorkflowTracer) StartWorkflow

func (w *WorkflowTracer) StartWorkflow(ctx context.Context, workflowType, action string) (context.Context, trace.Span)

StartWorkflow begins a new span for a workflow execution.

Jump to

Keyboard shortcuts

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