tracing

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tracing implements a super simple tracer/profiler based on go-metrics.

var tracer = NewTracer("", nil, nil)

func TraceThis() {
    defer tracer.Trace()()
    // do work here
}

func FunctionWithUglyName() {
    defer tracer.Trace("PrettyName")()
    // do work here
}

You will then be able to get information about timings for methods. When you don't specify a key, the package will walk the stack to find out the method name you want to trace. So if you don't want to incur that cost, use a key.

When used with the github.com/alexwbaule/middlewares package you can get a JSON document with the report from /audit/metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracer

type Tracer interface {
	// Trace the enter/leave of the method.
	// Record time spent in the method.
	// Returns a closure to close the method, best used in conjunction with defer, eg.: defer tr.Trace()()
	Trace(name ...string) func()
}

Tracer interface that represents a tracer in golang

func New

func New(name string, logger logrus.FieldLogger, registry metrics.Registry) Tracer

NewTracer creates a new tracer object with the specified configuration When the config is nil the tracer will use default values for the config, this is equivalent to

name: trace

Jump to

Keyboard shortcuts

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