Rucksack
A collection of logging/instrumenting tools for building Go apps
Basics
Package aims to simplify logging and instrumenting, so:
- package exposes functions, that work with default logger/instrumenter (which is usually not exposed)
- package is configured with ENV vars, like
LOG_TAGS=app:program go run program.go
Recommended way to use:
- import and use
"github.com/bsm/rucksack/log"
or"github.com/bsm/rucksack/met"
in non-main packages - import extension packages like
_ "github.com/bsm/rucksack/met/datadog"
only in main package
Logging
import "github.com/bsm/rucksack/log"
ENV:
LOG_NAME=projectname
(aliased asAPP_NAME
)LOG_TAGS=foo:bar,baz:qux
(aliased asAPP_TAGS
)LOG_LEVEL=INFO
LOG_STACK=true
(any non-empty value will enable stack logging; this is an expensive option)
Recommended way to use:
package main
import "github.com/bsm/rucksack/log"
func main() {
defer log.Sync()
defer log.ErrorOnPanic()
// do stuff
}
Metrics
import (
"github.com/bsm/rucksack/met"
_ "github.com/bsm/rucksack/met/datadog"
_ "github.com/bsm/rucksack/met/runtime"
)
ENV:
MET_NAME=projectname
(required; aliased asAPP_NAME
)MET_TAGS=foo:bar,baz:qux
(aliased asAPP_TAGS
)
With _ "github.com/bsm/rucksack/met/datadog"
imported:
MET_DATADOG=datadog-token
(required)MET_DATADOG_DISABLE_COMPRESSION=true
(optional, disables compression when sending data to DataDog API)
With _ "github.com/bsm/rucksack/met/runtime"
imported:
MET_RUNTIME=mem,heap,gc
(used set is equivalent toall
)
Optional ENV:
HOST=hostname
(auto-detected)PORT=8080
(optional)