Skip to content

jfbus/trace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trace

Status: development - expect bugs, breaking changes

Tracing library for Go.

It wraps in a single call :

  • logging,
  • metrics,
  • tracing.

We are currently using log15, go-metrics and appdash, but those libs can be swapped with other libs, provided you build wrappers for the lib.

Usage

// start a trace
t := trace.New(req.RequestURI, []trace.Wrapper{gometrics.Wrap(metrics.DefaultRegistry), log15.Wrap(log.DefaultLogger), appdash_trace.Wrap(appdashCollector)}, trace.FromHttpRequest(req))

// start a span
span := t.BeginSpan("DB transaction", trace.Metric("db.transaction"))
...
// send a log event
span.Event(trace.LogEvent(trace.LvlErr, "Unable to do something : %s", err))
...
span.End()

// update the "request" timer, log the request with the duration and the status code
t.End(trace.Metric("request"), trace.AddContext(trace.Context{"status": statusCode}), trace.Level(trace.LvlInfo))

Supporting new libraries

wrappers must implement the following interface :

type Wrapper interface {
	Setup(name string)
	Teardown()
	Child(name string) Wrapper
	Event(e Event)
}

License

MIT - see LICENSE

About

Tracing library for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages