containous/trace

Name: trace

Owner: Containous

Description: Package for error handling and error reporting

Forked from: gravitational/trace

Created: 2017-11-21 16:44:40.0

Updated: 2018-04-23 13:02:42.0

Pushed: 2017-11-21 16:52:55.0

Homepage: null

Size: 67

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Trace

GoDoc

Package for error handling and error reporting

Read more here:

http://gravitational.com/blog/golang_error_handling/

Capture file, line and function
rt (
 "github.com/gravitational/trace"


 someFunc() error {
eturn trace.Wrap(err)



 main() {
r := someFunc()
t.Println(err.Error()) // prints file, line and function

Emit structured logs to Elastic search using udpbeat

Add trace's document template to your ElasticSearch cluster

 -XPUT 'http://localhost:9200/_template/trace' -d@udbbeat/template.json

Start udpbeat UDP logs collector and emitter

et github.com/gravitational/udpbeat
eat

Hook up logger to UDP collector

In your code, attach a logrus hook to use udpbeat:

rt (
github.com/gravitational/trace"
og "github.com/sirupsen/logrus"


 main() {
ook, err := trace.NewUDPHook()
f err != nil {
   log.Fatalf(err)

og.SetHook(hook)

Done! You will get structured logs capturing output, log and error message. You can edit udpbeat/template.json to modify emitted fields to whatever makes sense to your app.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.