tracing

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderNoop  = "noop"
	ProviderLocal = "local"
	ProviderXray  = "xray"
	ProviderOtel  = "otel"
)

Variables

This section is empty.

Functions

func AddInstrumentorProvider added in v0.30.0

func AddInstrumentorProvider(name string, provider InstrumentorProvider)

func AddOtelTraceExporter added in v0.30.0

func AddOtelTraceExporter(name string, exporter OtelExporterFactory)

func AddTracerProvider added in v0.30.0

func AddTracerProvider(name string, provider TracerProvider)

func ContextTraceFieldsResolver

func ContextTraceFieldsResolver(ctx context.Context) map[string]any

func ContextWithSpan

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

func ContextWithTrace

func ContextWithTrace(ctx context.Context, trace *Trace) context.Context

func GetTraceIdFromContext added in v0.29.0

func GetTraceIdFromContext(ctx context.Context) *string

func NewAwsInstrumentorWithAppId added in v0.30.0

func NewAwsInstrumentorWithAppId(appId cfg.AppId) *awsInstrumentor

func NewAwsTracerWithInterfaces

func NewAwsTracerWithInterfaces(logger log.Logger, appId cfg.AppId, settings *XRaySettings) (*awsTracer, error)

func NewOtelHttpTracer added in v0.30.0

func NewOtelHttpTracer(ctx context.Context, config cfg.Config, _ log.Logger) (*otlptrace.Exporter, error)

func NewOtelInstrumentorWithAppId added in v0.30.0

func NewOtelInstrumentorWithAppId(appId cfg.AppId) *otelInstrumentor

func NewOtelTracerWithInterfaces added in v0.30.0

func NewOtelTracerWithInterfaces(logger log.Logger, tracer trace.Tracer) *otelTracer

func ProvideOtelTraceProvider added in v0.30.0

func ProvideOtelTraceProvider(ctx context.Context, config cfg.Config, logger log.Logger) (trace.TracerProvider, error)

func TraceToString

func TraceToString(trace *Trace) string

Types

type ContextMissingWarnSamplingConfig

type ContextMissingWarnSamplingConfig struct {
	Enabled  bool
	Interval time.Duration
}

type ContextMissingWarnStrategy

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

func NewContextMissingWarningLogStrategy

func NewContextMissingWarningLogStrategy(logger log.Logger) *ContextMissingWarnStrategy

func (ContextMissingWarnStrategy) ContextMissing

func (c ContextMissingWarnStrategy) ContextMissing(v interface{})

type Instrumentor added in v0.30.0

type Instrumentor interface {
	HttpHandler(h http.Handler) http.Handler
	HttpClient(baseClient *http.Client) *http.Client
	GrpcUnaryServerInterceptor() grpc.UnaryServerInterceptor
	GrpcServerHandler() stats.Handler
}

func NewAwsInstrumentor added in v0.30.0

func NewAwsInstrumentor(_ context.Context, config cfg.Config, _ log.Logger) (Instrumentor, error)

func NewLocalInstrumentor added in v0.30.0

func NewLocalInstrumentor() Instrumentor

func NewNoopInstrumentor added in v0.30.0

func NewNoopInstrumentor() Instrumentor

func NewOtelInstrumentor added in v0.30.0

func NewOtelInstrumentor(ctx context.Context, config cfg.Config, logger log.Logger) (Instrumentor, error)

func ProvideInstrumentor added in v0.30.0

func ProvideInstrumentor(ctx context.Context, config cfg.Config, logger log.Logger) (Instrumentor, error)

type InstrumentorProvider added in v0.30.0

type InstrumentorProvider func(ctx context.Context, config cfg.Config, logger log.Logger) (Instrumentor, error)

type LoggerErrorHandler

type LoggerErrorHandler struct{}

func NewLoggerErrorHandler

func NewLoggerErrorHandler() *LoggerErrorHandler

func (*LoggerErrorHandler) Channels

func (h *LoggerErrorHandler) Channels() []string

func (*LoggerErrorHandler) Level

func (h *LoggerErrorHandler) Level() int

func (*LoggerErrorHandler) Log

func (h *LoggerErrorHandler) Log(_ time.Time, _ int, _ string, _ []any, err error, data log.Data) error

type MessageWithTraceEncoder

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

func NewMessageWithTraceEncoder

func NewMessageWithTraceEncoder(strategy TraceIdErrorStrategy) *MessageWithTraceEncoder

func (MessageWithTraceEncoder) Decode

func (m MessageWithTraceEncoder) Decode(ctx context.Context, _ interface{}, attributes map[string]string) (context.Context, map[string]string, error)

func (MessageWithTraceEncoder) Encode

func (m MessageWithTraceEncoder) Encode(ctx context.Context, _ interface{}, attributes map[string]string) (context.Context, map[string]string, error)

type OtelExporterFactory added in v0.30.0

type OtelExporterFactory func(ctx context.Context, config cfg.Config, logger log.Logger) (*otlptrace.Exporter, error)

type OtelExporterSettings added in v0.30.0

type OtelExporterSettings struct {
	Endpoint    string        `cfg:"endpoint" default:"localhost:4318"`
	UrlPath     string        `cfg:"url_path" default:"/v1/traces"`
	Compression bool          `cfg:"compression" default:"true"`
	Insecure    bool          `cfg:"insecure" default:"false"`
	Timeout     time.Duration `cfg:"timeout" default:"10s"`
	Retry       RetryConfig   `cfg:"retry"`
}

type OtelSettings added in v0.30.0

type OtelSettings struct {
	Exporter      string  `cfg:"exporter" default:"otel_http"`
	SamplingRatio float64 `cfg:"sampling_ratio" default:"0.05"`
	SpanLimits
}

type RetryConfig added in v0.30.0

type RetryConfig struct {
	Enabled         bool          `cfg:"enabled" default:"false"`
	InitialInterval time.Duration `cfg:"initial_interval" default:"5s"`
	MaxInterval     time.Duration `cfg:"max_interval" default:"30s"`
	MaxElapsedTime  time.Duration `cfg:"max_elapsed_time" default:"300s"`
}

type SampleRule

type SampleRule struct {
	Description string  `json:"description" cfg:"description" default:"default"`
	ServiceName string  `json:"service_name" cfg:"service_name"`
	HttpMethod  string  `json:"http_method" cfg:"http_method"`
	UrlPath     string  `json:"url_path" cfg:"url_path"`
	FixedTarget uint64  `json:"fixed_target" cfg:"fixed_target" default:"1"`
	Rate        float64 `json:"rate" cfg:"rate" default:"0.05"`
}

type SamplingConfiguration

type SamplingConfiguration struct {
	Version int          `json:"version" cfg:"version" default:"1"`
	Default SampleRule   `json:"default" cfg:"default"`
	Rules   []SampleRule `json:"rules" cfg:"rules"`
}

type Span

type Span interface {
	AddAnnotation(key string, value string)
	AddError(err error)
	AddMetadata(key string, value interface{})
	Finish()
	GetId() string
	GetTrace() *Trace
}

func GetSpanFromContext

func GetSpanFromContext(ctx context.Context) Span

type SpanLimits added in v0.30.0

type SpanLimits struct {
	AttributeValueLengthLimit   int `cfg:"attribute_value_length_limit" default:"-1"`
	AttributeCountLimit         int `cfg:"attribute_count_limit" default:"128"`
	EventCountLimit             int `cfg:"event_count_limit" default:"128"`
	LinkCountLimit              int `cfg:"link_count_limit" default:"128"`
	AttributePerEventCountLimit int `cfg:"attribute_per_event_count_limit" default:"128"`
	AttributePerLinkCountLimit  int `cfg:"attribute_per_link_count_limit" default:"128"`
}

type Trace

type Trace struct {
	TraceId  string `json:"traceId"`
	Id       string `json:"id"`
	ParentId string `json:"parentId"`
	Sampled  bool   `json:"sampled"`
}

func GetTraceFromContext

func GetTraceFromContext(ctx context.Context) *Trace

func StringToTrace

func StringToTrace(traceId string) (*Trace, error)

func (*Trace) GetId

func (t *Trace) GetId() string

func (*Trace) GetParentId

func (t *Trace) GetParentId() string

func (*Trace) GetSampled

func (t *Trace) GetSampled() bool

func (*Trace) GetTraceId

func (t *Trace) GetTraceId() string

type TraceAble

type TraceAble interface {
	GetTrace() *Trace
}

type TraceIdErrorReturnStrategy

type TraceIdErrorReturnStrategy struct{}

func (TraceIdErrorReturnStrategy) TraceIdInvalid

func (t TraceIdErrorReturnStrategy) TraceIdInvalid(err error) error

type TraceIdErrorStrategy

type TraceIdErrorStrategy interface {
	TraceIdInvalid(err error) error
}

type TraceIdErrorWarningStrategy

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

func NewTraceIdErrorWarningStrategy

func NewTraceIdErrorWarningStrategy(logger log.Logger) *TraceIdErrorWarningStrategy

func NewTraceIdErrorWarningStrategyWithInterfaces

func NewTraceIdErrorWarningStrategyWithInterfaces(logger log.Logger, stacktraceProvider log.StackTraceProvider) *TraceIdErrorWarningStrategy

func (TraceIdErrorWarningStrategy) TraceIdInvalid

func (t TraceIdErrorWarningStrategy) TraceIdInvalid(err error) error

type Tracer

type Tracer interface {
	StartSpan(name string) (context.Context, Span)
	StartSpanFromContext(ctx context.Context, name string) (context.Context, Span)
	StartSubSpan(ctx context.Context, name string) (context.Context, Span)
}

func NewAwsTracer

func NewAwsTracer(_ context.Context, config cfg.Config, logger log.Logger) (Tracer, error)

func NewLocalTracer added in v0.26.6

func NewLocalTracer() Tracer

func NewNoopTracer

func NewNoopTracer() Tracer

func NewOtelTracer added in v0.30.0

func NewOtelTracer(ctx context.Context, config cfg.Config, logger log.Logger) (Tracer, error)

func ProvideTracer

func ProvideTracer(ctx context.Context, config cfg.Config, logger log.Logger) (Tracer, error)

type TracerProvider added in v0.30.0

type TracerProvider func(ctx context.Context, config cfg.Config, logger log.Logger) (Tracer, error)

type TracerSettings

type TracerSettings struct {
	Provider string `cfg:"provider"  default:"local" validate:"required"`
}

type XRaySettings

type XRaySettings struct {
	Address                     string
	CtxMissingStrategy          ctxmissing.Strategy
	SamplingStrategy            sampling.Strategy
	StreamingMaxSubsegmentCount int
}

type XrayTracerSettings added in v0.30.0

type XrayTracerSettings struct {
	AddressType                 string                `cfg:"addr_type" default:"local" validate:"required"`
	AddressValue                string                `cfg:"add_value" default:""`
	Sampling                    SamplingConfiguration `cfg:"sampling"`
	StreamingMaxSubsegmentCount int                   `cfg:"streaming_max_subsegment_count" default:"20"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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