rucksack

package module
v3.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

Rucksack

Build Status

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

GoDoc

import "github.com/bsm/rucksack/log"

ENV:

  • LOG_NAME=projectname (aliased as APP_NAME)
  • LOG_TAGS=foo:bar,baz:qux (aliased as APP_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

GoDoc

import (
  "github.com/bsm/rucksack/met"
  _ "github.com/bsm/rucksack/met/datadog"
  _ "github.com/bsm/rucksack/met/runtime"
)

ENV:

  • MET_NAME=projectname (required; aliased as APP_NAME)
  • MET_TAGS=foo:bar,baz:qux (aliased as APP_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 to all)

Optional ENV:

  • HOST=hostname (auto-detected)
  • PORT=8080 (optional)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(keys ...string) string

Env returns the value of first not-blank key

func Fields

func Fields(s string) map[string]interface{}

Fields parses key-value fields from a string

func Tags

func Tags(s string) []string

Tags parses tags from a string

Types

This section is empty.

Directories

Path Synopsis
Package log provides a 12-factor convenience wrapper around zap
Package log provides a 12-factor convenience wrapper around zap
met
Package met provides a 12-factor convenience wrapper around instruments
Package met provides a 12-factor convenience wrapper around instruments
datadog
Package datadog reports metrics to datadog, if included.
Package datadog reports metrics to datadog, if included.
runtime
Package runtime collects runtime metrics, if included.
Package runtime collects runtime metrics, if included.

Jump to

Keyboard shortcuts

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