btracer

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

实现文件 jaegertracing 基于 jaeger 实现的分布式追踪服务

接口文件 tracer 分布式追踪服务

Index

Constants

View Source
const (
	// EchoSpan echo span
	EchoSpan = "tracer_span_echo"
)
View Source
const (
	// Name module name
	Name = "JaegerTracing"
)
View Source
const (
	// RedisSpan redis span
	RedisSpan = "tracer_span_redis"
)

Variables

View Source
var (
	// ErrFactoryNotExist factory not exist
	ErrFactoryNotExist = errors.New("factory not exist")
)

Functions

func ClientInterceptor

func ClientInterceptor(tracer opentracing.Tracer) grpc.UnaryClientInterceptor

ClientInterceptor rpc拦截器

func NewSlowReporter

func NewSlowReporter(sender jaeger.Transport, metrics *jaeger.Metrics, probabilistic float64) jaeger.Reporter

NewSlowReporter creates a new reporter that sends spans out of process by means of Sender.

func ServerInterceptor

func ServerInterceptor(tracer opentracing.Tracer) grpc.UnaryServerInterceptor

ServerInterceptor server端rpc拦截器

Types

type EchoTracer

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

EchoTracer http request tracer

func (*EchoTracer) Begin

func (t *EchoTracer) Begin(ctx interface{})

Begin 开始捕捉

func (*EchoTracer) End

func (t *EchoTracer) End(ctx interface{})

End 结束捕捉

func (*EchoTracer) GetID

func (t *EchoTracer) GetID() string

func (*EchoTracer) SetTag

func (t *EchoTracer) SetTag(key string, val interface{})

type ISpan

type ISpan interface {
	Begin(ctx interface{})
	SetTag(key string, val interface{})
	GetID() string
	End(ctx interface{})
}

ISpan span interface

type ITracer

type ITracer interface {
	GetSpan(strategy string) (ISpan, error)

	GetTracing() interface{}
}

ITracer tracer interface

func BuildWithOption

func BuildWithOption(opts ...Option) ITracer

type MDReaderWriter

type MDReaderWriter struct {
	metadata.MD
}

MDReaderWriter metadata 读写

func (MDReaderWriter) ForeachKey

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

ForeachKey 为了 opentracing.TextMapReader ,参考 opentracing 代码

func (MDReaderWriter) Set

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

Set 为了 opentracing.TextMapWriter,参考 opentracing 代码

type Option

type Option func(*Parm)

Option config wraps

func WithHTTP

func WithHTTP(CollectorEndpoint string) Option

WithHTTP http://172.17.0.1:14268/api/traces

func WithProbabilistic

func WithProbabilistic(probabilistic float64) Option

WithProbabilistic 采样率 0 ~ 1

func WithSamplerType

func WithSamplerType(samplertype string) Option

WithSamplerType 采样类型

func WithServiceName

func WithServiceName(name string) Option

func WithSlowRequest

func WithSlowRequest(ms int) Option

WithSlowRequest 单次请求阀值(超过会有慢日志

func WithSlowSpan

func WithSlowSpan(ms int) Option

WithSlowSpan 单次调用阀值(超过会有慢日志

func WithSpanFactory

func WithSpanFactory(factory ...TracerFactory) Option

func WithUDP

func WithUDP(LocalAgentHostPort string) Option

WithUDP 172.17.0.1:6831

type Parm

type Parm struct {
	Name               string
	CollectorEndpoint  string  // jaeger http地址
	LocalAgentHostPort string  // jaeger udp地址
	Probabilistic      float64 // 采样率
	SamplerType        string
	SlowRequest        time.Duration // 一旦request超出设置的SlowRequest(ms)时间,则一定会有一条slow日志
	SlowSpan           time.Duration // 一旦span超出设置的SlowSpan(ms)时间,则一定会有一条slow日志
	ImportFactory      []TracerFactory
}

Parm https://github.com/jaegertracing/jaeger-client-go/blob/master/config/config.go

type RedisTracer

type RedisTracer struct {
	Cmd string
	// contains filtered or unexported fields
}

RedisTracer redis tracer

func (*RedisTracer) Begin

func (r *RedisTracer) Begin(ctx interface{})

Begin 开始监听

func (*RedisTracer) End

func (r *RedisTracer) End(ctx interface{})

End 结束监听

func (*RedisTracer) GetID

func (r *RedisTracer) GetID() string

func (*RedisTracer) SetTag

func (r *RedisTracer) SetTag(key string, val interface{})

type SpanFactory

type SpanFactory func(interface{}) (ISpan, error)

SpanFactory span 工厂

func CreateEchoTraceSpan

func CreateEchoTraceSpan() SpanFactory

createEchoTraceSpan 构建 echo tracer

func CreateRedisSpanFactory

func CreateRedisSpanFactory() SpanFactory

type TraceKey

type TraceKey int

TraceKey 主键类型

const (
	// RequestKey 请求的键值
	RequestKey TraceKey = 1000 + iota
)

type TracerFactory

type TracerFactory struct {
	Name    string
	Factory SpanFactory
}

Jump to

Keyboard shortcuts

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