trace

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: BSD-3-Clause Imports: 2 Imported by: 12

Documentation

Overview

Package trace provides tracing functionality. In ZAP mode (default), tracing is disabled - no OpenTelemetry dependencies. Use -tags=grpc to enable full OpenTelemetry tracing support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.15.6

type Config struct {
	ExporterConfig  ExporterConfig `json:"exporterConfig"`
	TraceSampleRate float64        `json:"traceSampleRate"`
	AppName         string         `json:"appName"`
	Version         string         `json:"version"`
}

Config holds tracing configuration

type EventOption added in v1.23.4

type EventOption interface{}

EventOption configures events

type ExporterConfig added in v0.15.6

type ExporterConfig struct {
	Type     ExporterType      `json:"type"`
	Endpoint string            `json:"endpoint"`
	Headers  map[string]string `json:"headers"`
	Insecure bool              `json:"insecure"`
}

ExporterConfig holds exporter configuration

type ExporterType added in v0.15.6

type ExporterType byte

ExporterType represents the type of trace exporter

const (
	Disabled ExporterType = iota
	GRPC
	HTTP
	ZAP
)

func ExporterTypeFromString added in v0.15.6

func ExporterTypeFromString(s string) (ExporterType, error)

ExporterTypeFromString parses an exporter type string

func (ExporterType) MarshalJSON added in v0.15.6

func (t ExporterType) MarshalJSON() ([]byte, error)

func (ExporterType) String added in v0.15.6

func (t ExporterType) String() string

func (*ExporterType) UnmarshalJSON added in v0.15.6

func (t *ExporterType) UnmarshalJSON(b []byte) error

type KeyValue added in v1.23.4

type KeyValue struct {
	Key   string
	Value Value
}

KeyValue represents a key-value attribute pair (otel compatible name)

func Bool added in v1.23.4

func Bool(key string, value bool) KeyValue

Bool creates a bool attribute

func Int added in v1.23.4

func Int(key string, value int) KeyValue

Int creates an int attribute

func Int64 added in v1.23.4

func Int64(key string, value int64) KeyValue

Int64 creates an int64 attribute

func String added in v1.23.4

func String(key, value string) KeyValue

String creates a string attribute

func Stringer added in v1.23.4

func Stringer(key string, value interface{ String() string }) KeyValue

Stringer creates a string attribute from a fmt.Stringer

type Span added in v1.23.4

type Span interface {
	End(options ...SpanEndOption)
	SetStatus(code StatusCode, description string)
	RecordError(err error, options ...EventOption)
	AddEvent(name string, options ...EventOption)
	SetAttributes(kv ...KeyValue)
}

Span represents a trace span

type SpanEndOption added in v1.23.4

type SpanEndOption interface{}

SpanEndOption configures span ending

type SpanStartOption added in v1.23.4

type SpanStartOption interface {
	// contains filtered or unexported methods
}

SpanStartOption configures span creation

func WithAttributes added in v1.23.4

func WithAttributes(...KeyValue) SpanStartOption

WithAttributes returns a SpanStartOption

type StatusCode added in v1.23.4

type StatusCode int

StatusCode represents span status

const (
	StatusUnset StatusCode = iota
	StatusOK
	StatusError
)

type Tracer

type Tracer interface {
	io.Closer
	Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span)
}

Tracer interface for tracing operations

var Noop Tracer = &noopTracer{}

Noop is a no-op tracer

func New added in v0.15.6

func New(Config) (Tracer, error)

New creates a new tracer (returns Noop in ZAP mode)

type Value added in v1.23.4

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

Value wraps attribute values

Jump to

Keyboard shortcuts

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