aitracer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Web   = "web"
	Http  = "http"
	RPC   = "rpc"
	GRPC  = "grpc"
	MySQL = "mysql"
	Redis = "redis"
	Kafka = "kafka"
)
View Source
const (
	LogLevelTrace = "trace"
	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
	LogLevelFatal = "fatal"
)

Variables

View Source
var (
	ErrUnsupportedFormat = errors.New("Unknown or unsupported Inject/Extract format")
	ErrInvalidCarrier    = errors.New("Invalid Inject/Extract carrier")
)

Functions

func ContextWithSpan

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

func InitGlobalTracer

func InitGlobalTracer(tracer Tracer)

func Inject

func Inject(sc SpanContext, format interface{}, carrier interface{}) error

func IsGlobalTracerRegistered

func IsGlobalTracerRegistered() bool

func Log

func Log(ctx context.Context, data LogData)

func SetGlobalTracer

func SetGlobalTracer(tracer Tracer)

Types

type BuiltinFormat

type BuiltinFormat byte
const (
	HTTPHeaders BuiltinFormat = iota
)

type Extractor

type Extractor interface {
	Extract(carrier interface{}) (SpanContext, error)
}

type FinishSpanOption

type FinishSpanOption struct {
	FinishTime time.Time
	Status     int64
}

type HTTPHeaderExtractSpanContext

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

func (*HTTPHeaderExtractSpanContext) ForeachBaggageItem

func (sc *HTTPHeaderExtractSpanContext) ForeachBaggageItem(h func(string, string) bool)

func (*HTTPHeaderExtractSpanContext) Sample

func (*HTTPHeaderExtractSpanContext) SpanID

func (sc *HTTPHeaderExtractSpanContext) SpanID() string

func (*HTTPHeaderExtractSpanContext) TraceID

func (sc *HTTPHeaderExtractSpanContext) TraceID() string

type HTTPHeadersCarrier

type HTTPHeadersCarrier http.Header

func (HTTPHeadersCarrier) ForeachKey

func (c HTTPHeadersCarrier) ForeachKey(handler func(key, val string) error) error

func (HTTPHeadersCarrier) Set

func (c HTTPHeadersCarrier) Set(key, val string)

type HTTPHeadersExtractor

type HTTPHeadersExtractor struct {
}

func (*HTTPHeadersExtractor) Extract

func (extractor *HTTPHeadersExtractor) Extract(carrier interface{}) (SpanContext, error)

type HTTPHeadersInjector

type HTTPHeadersInjector struct {
}

func (*HTTPHeadersInjector) Inject

func (injector *HTTPHeadersInjector) Inject(sc SpanContext, carrier interface{}) error

type Injector

type Injector interface {
	Inject(sc SpanContext, carrier interface{}) error
}

type LogData

type LogData struct {
	Message   []byte
	Timestamp time.Time
	FileName  string
	FileLine  int64
	LogLevel  string
	Source    string
}

type PropagatorConfig

type PropagatorConfig struct {
	Format    interface{}
	Injector  Injector
	Extractor Extractor
}

type SampleStrategy

type SampleStrategy byte
const (
	SampleStrategyUnknown SampleStrategy = iota
	SampleStrategyNotSampled
	SampleStrategySampled
)

type Span

type Span interface {
	Finish()
	FinishWithOption(opt FinishSpanOption)
	Context() SpanContext

	SetBaggageItem(restrictedKey, value string) Span
	BaggageItem(restrictedKey string) string

	SetTag(key string, value interface{}) Span
	SetTagString(key string, value string) Span
	SetTagFloat64(key string, value float64) Span
	SetTagInt64(key string, value int64) Span
}

func GetSpanFromContext

func GetSpanFromContext(ctx context.Context) Span

func StartClientSpan

func StartClientSpan(operationName string, opts ...StartSpanOption) Span

func StartClientSpanFromContext

func StartClientSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

func StartServerSpan

func StartServerSpan(operationName string, opts ...StartSpanOption) Span

func StartServerSpanFromContext

func StartServerSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

func StartSpan

func StartSpan(operationName string, opts ...StartSpanOption) Span

func StartSpanFromContext

func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

type SpanContext

type SpanContext interface {
	TraceID() string
	SpanID() string
	Sample() (strategy SampleStrategy, weight int)
	ForeachBaggageItem(func(string, string) bool)
}

func Extract

func Extract(format interface{}, carrier interface{}) (SpanContext, error)

type StartSpanConfig

type StartSpanConfig struct {
	ServerResource string

	ClientResource    string
	ClientService     string
	ClientServiceType string
	// contains filtered or unexported fields
}

type StartSpanOption

type StartSpanOption func(*StartSpanConfig)

func ChildOf

func ChildOf(sc SpanContext) StartSpanOption

func ClientResourceAs

func ClientResourceAs(clientServiceType string, clientService string, clientResource string) StartSpanOption

func ServerResourceAs

func ServerResourceAs(resource string) StartSpanOption

type Tracer

type Tracer interface {
	Start()
	Extract(format interface{}, carrier interface{}) (SpanContext, error)
	Inject(sc SpanContext, format interface{}, carrier interface{}) error

	StartServerSpan(operationName string, opts ...StartSpanOption) Span
	StartServerSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

	StartClientSpan(operationName string, opts ...StartSpanOption) Span
	StartClientSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

	StartSpan(operationName string, opts ...StartSpanOption) Span
	StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context)

	Log(ctx context.Context, data LogData)
	Stop()
}

func GlobalTracer

func GlobalTracer() Tracer

func NewTracer

func NewTracer(serviceType, service string, opts ...TracerOption) Tracer

type TracerConfig

type TracerConfig struct {
	ServiceType string
	Service     string

	SenderChanSize int
	SenderSock     string
	SenderNumber   int

	Logger logger.Logger

	EnableMetric bool
	MetricSock   string

	EnableLogSender   bool
	LogSenderSock     string
	LogSenderNumber   int
	LogSenderChanSize int

	SettingsFetcherSock string

	PropagatorConfigs []PropagatorConfig

	ServerRegisterSock string
}

type TracerOption

type TracerOption func(*TracerConfig)

func WithLogSender

func WithLogSender(enable bool) TracerOption

func WithLogger

func WithLogger(logger logger.Logger) TracerOption

func WithMetrics

func WithMetrics(enable bool) TracerOption

func WithMetricsAddress

func WithMetricsAddress(metricAddress string) TracerOption

func WithPropagator

func WithPropagator(format interface{}, injector Injector, extractor Extractor) TracerOption

func WithSenderChanSize

func WithSenderChanSize(chanSize int) TracerOption

func WithSenderNumber

func WithSenderNumber(senderNumber int) TracerOption

func WithSenderSock

func WithSenderSock(senderSock string) TracerOption

func WithService

func WithService(serviceType string, service string) TracerOption

Jump to

Keyboard shortcuts

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