Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

alibaba-archive/gear-tracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gear-tracing

Build Status Coverage Status License GoDoc

Opentracing middleware for Gear.

Demo

package main

import (
  "time"

  "github.com/opentracing/basictracer-go"
  "github.com/opentracing/opentracing-go"
  "github.com/teambition/gear"
  "github.com/teambition/gear-tracing"
)

func init() {
  opentracing.SetGlobalTracer(basictracer.New(basictracer.NewInMemoryRecorder()))
  // use zipkin tracer
  // collector, err := zipkintracer.NewScribeCollector("127.0.0.1:9410", 3*time.Second)
  // if err == nil {
  //   tracer, err := zipkintracer.NewTracer(zipkintracer.NewRecorder(collector, false, "https://github.com", "gear-tracing"))
  //   if err == nil {
  //     opentracing.SetGlobalTracer(tracer)
  //   }
  // }
}

func main() {
  app := gear.New()
  router := gear.NewRouter()
  router.Use(tracing.New())
  router.Get("/", func(ctx *gear.Context) error {
    span := opentracing.SpanFromContext(ctx)
    assert.NotNil(span)
    span.SetTag("testing", "testing")
    return ctx.HTML(200, "Test Tracing")
  })

  app.UseHandler(router)
  app.Listen(":3000")
}

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •