opentracing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 10 Imported by: 0

README

opentracing中间件使用方法

安装

go get github.com/hanguangbaihuo/sparrow_cloud_go

iris框架中使用方法

import "github.com/hanguangbaihuo/sparrow_cloud_go/middleware/opentracing"
func main() {
    // 追踪链配置:初始化Jaeger为GlobalTracer
    // 初始化失败则程序直接结束
    closer := opentracing.InitGlobalTracer("YourServiceName")
    defer closer.Close()
    // 初始化iris app
    app := iris.New()
    // 使用opentracing中间件,从header中提取父span,并存储至中间件
    app.Use(opentracing.Serve("YourServiceName"))
    ...
}

注意

该中间件需要配合restclient包使用,才能实现追踪链
restclient包的地址:github.com/hanguangbaihuo/sparrow_cloud_go/restclient

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActiveSpan opentracing.Span

ActiveSpan is global opentraing parent span, will be initialized in opentracing Serve function restclient use it to generate child span

Functions

func InitGlobalTracer

func InitGlobalTracer(serviceName string) io.Closer

InitGlobalTracer is for setting Global Tracer. you must do the function in main() function like follow:

closer := InitGlobalTracer("your_service_name")
defer closer.Close()

func Serve

func Serve(operationName string) func(context.Context)

Serve is opentracing middleware function parameter operationName is a operaion name, usually named it service name

Types

This section is empty.

Jump to

Keyboard shortcuts

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