opstocat

package module
v0.0.0-...-ea0dbfa Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2016 License: MIT Imports: 23 Imported by: 0

README

Opstocat

Collection of Ops related patterns for Go apps at GitHub.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrefixedStatter

func PrefixedStatter(prefix string, statter g2s.Statter) g2s.Statter

func ReadAppConfig

func ReadAppConfig(config ConfigWrapper, appconfigPath string)

Look for an available appconfig environment json file.

func ReadEnv

func ReadEnv(config ConfigWrapper)

Fill out the app config from values in the environment. The env keys are the same as the json marshal keys in the config struct.

func ReadEnvConfig

func ReadEnvConfig(config ConfigWrapper, appconfigPath, env string) error

Decode the environment's JSON file inside the appconfig path into the given config struct.

func SendPeriodicStats

func SendPeriodicStats(duration string, config ConfigWrapper, callback func(keyprefix string)) error

func SetupLogger

func SetupLogger(config ConfigWrapper)

func WritePid

func WritePid(config ConfigWrapper)

Types

type ConfigWrapper

type ConfigWrapper interface {
	OpstocatConfiguration() *Configuration
	SetupLogger()
}

type Configuration

type Configuration struct {
	App              string
	Env              string `json:"APP_ENV"`
	AppConfigPath    string `json:"APP_CONFIG_PATH"`
	PidPath          string `json:"APP_PIDPATH"`
	LogFile          string `json:"APP_LOG_FILE"`
	StatsDAddress    string `json:"STATSD"`
	ForceStats       string `json:"FORCE_STATS"`
	HaystackUser     string `json:"FAILBOT_USERNAME"`
	HaystackPassword string `json:"FAILBOT_PASSWORD"`
	HaystackEndpoint string `json:"FAILBOT_URL"`
	SyslogAddr       string `json:"SYSLOG_ADDR"`
	Sha              string
	Hostname         string
}

func NewConfiguration

func NewConfiguration(workingdir string) *Configuration

func (*Configuration) ShowPeriodicStats

func (c *Configuration) ShowPeriodicStats() bool

type HaystackReporter

type HaystackReporter struct {
	Endpoint string
	Hostname string
}

func NewHaystackReporter

func NewHaystackReporter(config *Configuration) (*HaystackReporter, error)

func (*HaystackReporter) Report

func (r *HaystackReporter) Report(err error, data grohl.Data) error

type NoOpStatter

type NoOpStatter struct{}

func (*NoOpStatter) Counter

func (s *NoOpStatter) Counter(sampleRate float32, bucket string, n ...int)

func (*NoOpStatter) Gauge

func (s *NoOpStatter) Gauge(sampleRate float32, bucket string, value ...string)

func (*NoOpStatter) Timing

func (s *NoOpStatter) Timing(sampleRate float32, bucket string, d ...time.Duration)

type PrefixStatter

type PrefixStatter struct {
	Prefix  string
	Statter g2s.Statter
}

func (*PrefixStatter) Counter

func (s *PrefixStatter) Counter(sampleRate float32, bucket string, n ...int)

func (*PrefixStatter) Gauge

func (s *PrefixStatter) Gauge(sampleRate float32, bucket string, value ...string)

func (*PrefixStatter) Timing

func (s *PrefixStatter) Timing(sampleRate float32, bucket string, d ...time.Duration)

type StatsdSignedWriter

type StatsdSignedWriter struct {
	io.Writer
	Key []byte
}

`StatsdSignedWriter` wraps an `io.Writer`, prefixing writes with an HMAC, nonce and timestamp as described in <https://github.com/github/statsd-ruby/pull/9>.

As an example:

conn, err := net.DialTimeout("udp", "endpoint.example.com:8126", 2*time.Second)
if err != nil {
  // handle err
}

writer := &opstocat.StatsdSignedWriter{Writer: conn, Key: []byte("supersecret")}
statter := g2s.New(writer)
statter.Counter(1.0, "foo", 1) // :banana: out

func (*StatsdSignedWriter) Write

func (s *StatsdSignedWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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