trace

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientTransportContext

func NewClientTransportContext(ctx context.Context, tp Transporter) context.Context

NewClientTransportContext 新建客户端链路上下文

func NewServerTransportContext

func NewServerTransportContext(ctx context.Context, tp Transporter) context.Context

NewServerTransportContext 新建服务端链路上下文

func SetOperation

func SetOperation(ctx context.Context, op string)

SetOperation sets the transport operation.

func WithClient

func WithClient(opts ...options.Option) middleware.MiddleWare

WithClient returns a new client middleware for OpenTelemetry.

func WithPropagator

func WithPropagator(propagator propagation.TextMapPropagator) options.Option

WithPropagator with tracer propagator.

func WithServer

func WithServer(opts ...options.Option) middleware.MiddleWare

WithServer returns a new server middleware for OpenTelemetry.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) options.Option

WithTracerProvider with tracer provider.

Types

type ClientHandler

type ClientHandler struct{}

ClientHandler 客户端追踪

func (*ClientHandler) HandleConn

func (c *ClientHandler) HandleConn(ctx context.Context, cs stats.ConnStats)

HandleConn exists to satisfy gRPC stats.Handler.

func (*ClientHandler) HandleRPC

func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)

HandleRPC implements per-RPC tracing and stats instrumentation.

func (*ClientHandler) TagConn

TagConn exists to satisfy gRPC stats.Handler.

func (*ClientHandler) TagRPC

TagRPC implements per-RPC context management.

type EndPointer

type EndPointer interface {
	Endpoint() (*url.URL, error)
}

EndPointer 注册点

type Header interface {
	Get(key string) string
	Set(key string, value string)
	Keys() []string
}

Header 抽象获取协议头部的动作行为

type Kind

type Kind string
const (
	KindGRPC Kind = "GRPC"
	KindHTTP Kind = "HTTP"
)

func (Kind) String

func (k Kind) String() string

type Metadata

type Metadata struct {
	Name string
}

func (Metadata) Extract

Extract reads cross-cutting concerns from the carrier into a Context.

func (Metadata) Fields

func (m Metadata) Fields() []string

Fields returns the keys who's values are set with Inject.

func (Metadata) Inject

func (m Metadata) Inject(ctx context.Context, carrier propagation.TextMapCarrier)

Inject set cross-cutting concerns from the Context into the carrier.

type Server

type Server interface {
	Start(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

Server 链路追踪的服务

type Tracer

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

func NewTracer

func NewTracer(kind trace.SpanKind, opts ...options.Option) *Tracer

NewTracer 创建追踪器

func (*Tracer) End

func (t *Tracer) End(ctx context.Context, span trace.Span, m interface{}, err error)

End 完成追踪

func (*Tracer) Start

func (t *Tracer) Start(ctx context.Context, operation string, carrier propagation.TextMapCarrier) (context.Context, trace.Span)

Start 开始追踪

type Transport

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

Transport is an HTTP transport.

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

Endpoint returns the transport endpoint.

func (*Transport) Kind

func (tr *Transport) Kind() Kind

Kind returns the transport kind.

func (*Transport) Operation

func (tr *Transport) Operation() string

Operation returns the transport operation.

func (*Transport) PathTemplate

func (tr *Transport) PathTemplate() string

PathTemplate returns the http path template.

func (*Transport) Request

func (tr *Transport) Request() *http.Request

Request returns the HTTP request.

func (*Transport) RequestHeader

func (tr *Transport) RequestHeader() Header

RequestHeader returns the request header.

func (*Transport) ResponseHeader

func (tr *Transport) ResponseHeader() Header

ResponseHeader returns the reply header.

type Transporter

type Transporter interface {
	// Kind 返回 KindGRPC or KindHTTP 用于区分协议调用
	Kind() Kind

	// Endpoint
	// Server Transporter: grpc://127.0.0.1:9000
	// Client Transporter: discovery://provider-demo
	Endpoint() string

	// Operation protobuf 行为
	Operation() string

	// RequestHeader 返回请求头
	RequestHeader() Header

	// ResponseHeader 返回响应头
	ResponseHeader() Header
}

Transporter 链路追踪的上下文

func FromClientTransportContext

func FromClientTransportContext(ctx context.Context) (Transporter, bool)

FromClientTransportContext 通过客户端context获取链路信息

func FromServerTransportContext

func FromServerTransportContext(ctx context.Context) (Transporter, bool)

FromServerTransportContext 通过服务端context获取链路信息

Jump to

Keyboard shortcuts

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