Skip to content

Simple, lightweight tracing library for Go. For performance and system analysis.

License

Notifications You must be signed in to change notification settings

jamesrr39/go-tracing

Repository files navigation

go-tracing

go-tracing is a lightweight, simple, easy-to-use request tracing library. You can use it to see what parts of your system take a long time, and which parts are quicker. There are more complex implementations of a tracer that can export to different services, etc, but this one aims to be straightforward and not require any other service setup, and run on your computer.

It consists of 2 parts:

  • The tracing package at github.com/jamesrr39/go-tracing. You call this part in your application. This then writes the traces to a file (or other writer). It uses the streamtostorage format, more info here: Code | GoDoc.
  • The tracingviz/tracingviz-main.go application. This reads the file, and converts it into an html file. This html file can then be opened and you can see all of your traces. This file is designed to be portable, so you can copy it between computers.

Tracing using the tracing package relies heavily on the context, so you must have added the tracer and that specific trace to the context. The provided Middleware function will do that for you, if you want to use it for an HTTP server. If you want to use it for something, you can look at the Middleware function and adapt it for what you want.

Installation

# get the library to instrument your code
go get github.com/jamesrr39/go-tracing

# install the program to generate HTML visualisations of the trace outputs
go get github.com/jamesrr39/go-tracing/tracingviz

To run the example:

  • go run example/example_http_server.go (this will print out the location of the newly-creating tracer file)
  • go run tracingviz/tracingviz-main.go <path-to-tracer-file> <desired-html-output-file-path> (or tracingviz <path-to-tracer-file> <desired-html-output-file-path> if you used installed tracingviz with go get/go install)
  • open <desired-html-output-file-path> with a modern web browser.

What you should see: Selection_097

About

Simple, lightweight tracing library for Go. For performance and system analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages