tracing

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

Tracing模块

Tracing模块封装链路追踪功能,支持jeager。

使用示例:

import (
	"gitee.com/peyton1991/kuat/tracing"
)

func Init() (err error) {
	...
	if err = tracing.Init(); err != nil {
		return
	}
	...
}

Documentation

Index

Constants

View Source
const (
	HttpTag       = "http"
	ServerSpan    = "server"
	HttpURLTag    = "http.url"
	HttpMethodTag = "http.method"
	PeerIpV4Tag   = "peer.ipv4"
	Error         = "error"
	HTTPCode      = "http.status_code"
)

Variables

View Source
var (
	String = xlog.String
)

Functions

func Close

func Close()

func CreateSpanWithHttp

func CreateSpanWithHttp(req *http.Request) (span opentracing.Span)

CreateSpanWithHttp 从http请求中解析出trace信息,如果没有自动初始化span.

func CustomTag

func CustomTag(key string, val interface{}) opentracing.Tag

func HeaderExtractor

func HeaderExtractor(hdr map[string][]string) opentracing.StartSpanOption

func Init

func Init(conf *Config) (err error)

Init 初始化全局的Trace

func InjectHeader

func InjectHeader(h *http.Header, span opentracing.Span) (err error)

InjectSpan

func SpanFromContext

func SpanFromContext(ctx context.Context) opentracing.Span

func StartSpanFromContext

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

func TagComponent

func TagComponent(component string) opentracing.Tag

func TagSpanKind

func TagSpanKind(kind string) opentracing.Tag

Types

type Config

type Config struct {
	ServiceName string                 `json:"serviceName" yaml:"serviceName"`
	RPCMetrics  bool                   `json:"rpcMetrics" yaml:"rpcMetrics"`
	Tags        []opentracing.Tag      `json:"tags" yaml:"tags"`
	Sampler     *config.SamplerConfig  `json:"sampler" yaml:"sampler"`
	Reporter    *config.ReporterConfig `json:"reporter" yaml:"reporter"`
	Headers     *jaeger.HeadersConfig  `json:"headers" yaml:"headers"`
}

func DefaultConfig

func DefaultConfig() Config

type MetadataReaderWriter

type MetadataReaderWriter struct {
	MD map[string][]string
}

type NullStartSpanOption

type NullStartSpanOption struct{}

func (NullStartSpanOption) Apply

func (n NullStartSpanOption) Apply(options *opentracing.StartSpanOptions)

Jump to

Keyboard shortcuts

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