The plugins of opentracing-go.

Overview

OpenTracing-Go-Plugins

The plugins of opentracing-go.

Installation

go get -u github.com/yuewokeji/opentracing-go-plugins

Configuration

Initialize a tracer

Create a tracer such as jaeger.

package main

import (
	"github.com/opentracing/opentracing-go"
	"github.com/uber/jaeger-client-go"
	"github.com/uber/jaeger-client-go/transport"
	"io"
)

func initJaeger(service, url string) (opentracing.Tracer, io.Closer) {
	sender := transport.NewHTTPTransport(url)
	reporter := jaeger.NewRemoteReporter(sender, jaeger.ReporterOptions.Logger(jaeger.StdLogger))

	// samples 100% of traces
	tracer, closer := jaeger.NewTracer(service, jaeger.NewConstSampler(true), reporter)
	return tracer, closer
}

Initialize the global tracer

Let's initialize the global tracer, that's because the function opentracing.GlobalTracer() returns a no-op tracer by default.

func initGlobalTracer() io.Closer {
	// the closer can be used in shutdown hooks
	tracer, closer := initJaeger("hello-world", "https://your-reporter-url")

	opentracing.SetGlobalTracer(tracer)
	return closer
}

Plugin Summary

  1. goroutine
  2. gin
  3. goredis
  4. gorm
  5. grpc
  6. http client
  7. omnipotent
Issues
  • 【请教】按照 Readme 添加了初始化和注入 gorm/gin Plugin 后 jaeger-ui 中没有新的服务

    【请教】按照 Readme 添加了初始化和注入 gorm/gin Plugin 后 jaeger-ui 中没有新的服务

    大致代码(Gin 部分)如下,不知道是不是我哪里理解或者使用方式不当?

    之前链路追踪实践的经验比较少,如果有什么小白的地方作者还望大大多多包涵(抱拳)。

    // main.go
    
    var (
    	tracerCloser io.Closer
    )
    
    func main() {
            // 调用 tracer 初始化
    	tracerCloser = initialize.InitGlobalTracer()
            // 调用 gin 初始化
    	core.RunServer()
    	err := tracerCloser.Close()
    	if err != nil {
    		fmt.Println("tracerCloser failed:", err.Error())
    	}
    }
    
    //  initialize.jaeger.go
    package initialize
    
    import (
    	"io"
    
    	"github.com/opentracing/opentracing-go"
    	"github.com/temptup/temptup.api/global"
    	"github.com/uber/jaeger-client-go"
    	"github.com/uber/jaeger-client-go/transport"
    )
    
    func initJaeger(service, url string) (opentracing.Tracer, io.Closer) {
    	sender := transport.NewHTTPTransport(url)
    	reporter := jaeger.NewRemoteReporter(sender, jaeger.ReporterOptions.Logger(jaeger.StdLogger))
    
    	// samples 100% of traces
    	tracer, closer := jaeger.NewTracer(service, jaeger.NewConstSampler(true), reporter)
    	return tracer, closer
    }
    
    func InitGlobalTracer() io.Closer {
    	// the closer can be used in shutdown hooks
    	tracer, closer := initJaeger("demo", "http://127.0.0.1")
    
    	opentracing.SetGlobalTracer(tracer)
    	return closer
    }
    
    
    // core.server.go
    func RunServer() {
        router := initialize.Routers()
    
        s := initServer("127.0.0.1:8888", router)
    
        go func() {
            fmt.Println(s.ListenAndServe().Error())
        }()
    
        graceful.ShutdownAndCleanup(func() {
            _, cancel := context.WithTimeout(context.Background(), 5*time.Second)
            cancel()
        })
    }
    
    // initialize.router.go
    var Router = gin.Default()
    
    // jaeger
    func Routers() *gin.Engine {
    
        var Router = gin.Default()
    
        // 注入 trace
        Router.Use(otgin.NewMiddleware(Router))
    
        // swagger
        Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
        // ......
        fmt.Println("register swagger handler")
    
        return Router
    }
    
    opened by FWangZil 2
Releases(v0.0.1)
Opentracing factory to setup by multiples vendors

telemetry Opentracing factory to setup by multiples vendors. Usage telemetry.InitTracer( telemetry.WithJaeger(os.Getenv("APP_NAME")), telemetr

Leroy Merlin Brasil 3 Jul 23, 2021
Progress OpenEdge Profiler data parsing to OpenTracing format

openedge-profiler-parser Progress OpenEdge Profiler data parsing to OpenTracing format. Prerequisites In order to RUN you will be enough with Docker:

Baltic Amadeus 4 Nov 9, 2021
Enable requests served by caddy for distributed tracing via The OpenTracing Project.

caddy-opentracing Enable requests served by caddy for distributed tracing via The OpenTracing Project. Dependencies The Go OpenTracing Library Jaeger,

null 11 Nov 29, 2021
Package for writing Nagios/Icinga/et cetera plugins in Go (golang)

nagiosplugin Package for writing Nagios/Icinga/et cetera plugins in Go (golang). Documentation See http://godoc.org/github.com/olorin/nagiosplugin. Us

Sharif Olorin 67 Oct 27, 2021
Kubernetes plugins for EdgeGallery

Plugins 介绍 the edgegallery plugins repo 软件架构 软件架构说明 安装教程 xxxx xxxx xxxx 使用说明 xxxx xxxx xxxx 参与贡献 Fork 本仓库 新建 Feat_xxx 分支 提交代码 新建 Pull Request 码云特技 使用

EdgeGallery 19 Oct 19, 2021
CoreDNS is a DNS server that chains plugins

CoreDNS is a DNS server/forwarder, written in Go, that chains plugins. Each plugin performs a (DNS) function. CoreDNS is a Cloud Native Computing Foun

CoreDNS 8.5k Dec 4, 2021
create boilerplate structure for neovim plugins

boilit Boil yourself a sweet plugin Installation • Usage Ain't nobody got time to create plugin directories: boilit yourself! boilit creates boilerpla

Gennaro Tedesco 26 Nov 23, 2021
Extend KIND networking capabilities with plugins using the KIND API

kind-networking-plugins Plugins to extend KIND networking capabilities with plugins using the KIND API These plugins were used for the Kubecon EU 2021

Antonio Ojea 17 Sep 23, 2021
A command tool to help user install oh-my-zsh plugins fast in a comfortable way

zshx A command tool to help user install oh-my-zsh plugins fast in a comfortable way. in other way, it is a zsh plugin package manager. How to use the

xylon 5 Aug 2, 2021
🎉 An awesome version control tool for protoc and its related plugins.

❤️ PowerProto is actively maintained! Any questions in use can be directly raised issue, I will respond to you as fast as possible. If you think the p

storyicon 117 Nov 25, 2021
Go Support Code For Writing Falcosecurity Plugins

plugin-sdk-go Go package to facilitate writing Falco/Falco libs plugins. Before using this package, review the developer's guide which fully documents

Mark Stemm 2 Sep 20, 2021
go program that installs and customizes ohmyzsh tmux vim via various plugins and other nice to haves

Pimp-My-Shell Table of Contents Pimp-My-Shell Install Usage About Resources Tmux Hotkeys VIM Hotkeys Adjusting Custom Aliases Mac Fix Terminal bind ke

null 4 Nov 29, 2021
Kong Api Gateway Plugins for golang

Prerequisites: Windows Docker. Build Command: docker build -t kong-plugins . Run Command: docker run -ti --rm --name kong-plugins -e "KONG_DATABASE=of

Karan Gupta 1 Dec 2, 2021