trace

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: Apache-2.0 Imports: 10 Imported by: 3

README

trace

框架支持 opentracing,但开源版默认不开启。

推荐使用 jaeger

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTraceID

func GetTraceID(ctx context.Context) (traceID string)

GetTraceID 查询 trace_id

func InjectTraceHeader

func InjectTraceHeader(ctx opentracing.SpanContext, req *http.Request)

InjectTrace 注入 OpenTracing 头信息

func StartSpanFromContext

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

StartSpanFromContext starts and returns a Span with `operationName`, using any Span found within `ctx` as a ChildOfRef. If no such parent could be found, StartSpanFromContext creates a root (parentless) Span.

The second return value is a context.Context object built around the returned Span.

Example usage:

SomeFunction(ctx context.Context, ...) {
    sp, ctx := opentracing.StartSpanFromContext(ctx, "SomeFunction")
    defer sp.Finish()
    ...
}

func StartSpanServerHTTP

func StartSpanServerHTTP(r *http.Request, operation string) (req *http.Request, span opentracing.Span)

StartSpanServerHTTP 启动http服务的span

func Stop

func Stop()

Stop 停止 trace 协程

Types

This section is empty.

Jump to

Keyboard shortcuts

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