Documentation ¶
Overview ¶
pkg metrics is for gathering metrics.
Index ¶
- func AppName() string
- func DataDogHttp(apiKey, hostName, appName string, logger Logger)
- func DataDogMsg(apiKey, hostName, appName string, logger Logger)
- func DataDogMsgSync(apiKey, hostName, appName string, logger Logger)
- func DoProcess(m Processor, b []byte) error
- func DoProcessWithContext(ctx context.Context, m ProcessorWithContext, b []byte) error
- func HostName() string
- func MsgErr()
- func MsgProc()
- func MsgRx()
- func MsgTx()
- func ReadHttpCounters(m *HttpCounters)
- func ReadMsgCounters(m *MsgCounters)
- func Request()
- func StatusBadRequest()
- func StatusInternalServerError()
- func StatusNotFound()
- func StatusOK()
- func StatusServiceUnavailable()
- func StatusUnauthorized()
- func Written(n int64)
- type HttpCounters
- type Logger
- type MsgCounters
- type Processor
- type ProcessorWithContext
- type Timer
- type TimerStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataDogHttp ¶
DataDogHttp initiates collection of HTTP and system metrics every 60s. if apiKey is non zero metrics are send to Data Dog otherwise they are logged using logger. Errors are logged with logger. If logger is nil log messages are discarded.
func DataDogMsg ¶
DataDogMsg initiates collection of messaging and system metrics every 60s. if apiKey is non zero metrics are send to Data Dog otherwise they are logged using logger. Errors are logged with logger. If logger is nil log messages are discarded
func DataDogMsgSync ¶
Sends current metrics immediately
func DoProcessWithContext ¶
func DoProcessWithContext(ctx context.Context, m ProcessorWithContext, b []byte) error
DoProcess executes m.Process with messaging metrics. pass a context to processor to catch system stop signal
func MsgErr ¶
func MsgErr()
MsgErr increments the message error counter. It is safe for concurrent access.
func MsgProc ¶
func MsgProc()
MsgProc increments the message processed counter. It is safe for concurrent access.
func MsgRx ¶
func MsgRx()
MsgRx increments the message received counter. It is safe for concurrent access.
func MsgTx ¶
func MsgTx()
MsgTx increments the message transmitted counter. It is safe for concurrent access.
func ReadHttpCounters ¶
func ReadHttpCounters(m *HttpCounters)
ReadHttpCounters populates m with http counter delta values since last time it was called.
func ReadMsgCounters ¶
func ReadMsgCounters(m *MsgCounters)
ReadMsgCounters populates m with message counter delta values since last time it was called.
func Request ¶
func Request()
Request increments the http request counter. It is safe for concurrent access.
func StatusBadRequest ¶
func StatusBadRequest()
StatusBadRequest increments the http response 400 counter. It is safe for concurrent access.
func StatusInternalServerError ¶
func StatusInternalServerError()
StatusInternalServerError increments the http response 500 counter. It is safe for concurrent access.
func StatusNotFound ¶
func StatusNotFound()
StatusNotFound increments the http response 404 counter. It is safe for concurrent access.
func StatusOK ¶
func StatusOK()
StatusOK increments the http response 200 counter. It is safe for concurrent access.
func StatusServiceUnavailable ¶
func StatusServiceUnavailable()
StatusServiceUnavailable increments the http response 503 counter. It is safe for concurrent access.
func StatusUnauthorized ¶
func StatusUnauthorized()
StatusUnauthorized increments the http response 400 counter. It is safe for concurrent access.
Types ¶
type HttpCounters ¶
type HttpCounters struct { // Request is the count of http requests. Request uint64 // StatusOK is the count of http 200 responses. StatusOK uint64 // StatusBadRequest is the count of http 400 responses. StatusBadRequest uint64 StatusUnauthorized uint64 // StatusNotFound is the count of http 404 responses. StatusNotFound uint64 // StatusInternalServerError is the count of http 500 responses. StatusInternalServerError uint64 StatusServiceUnavailable uint64 // Written is the number of bytes written. Written uint64 // At is the time the counters were sampled at. At time.Time }
A HttpCounters records http counters.
type Logger ¶
type Logger interface {
Printf(string, ...interface{})
}
Logger defines an interface for logging.
type MsgCounters ¶
type MsgCounters struct { // Rx is the count of messages received. Rx uint64 // Tx is the count of messages transmitted. Tx uint64 // Proc is the count of messages processed. Proc uint64 // Err is the count of errored messages. Err uint64 // At is the time the counters were sampled at. At time.Time }
A MsgCounters records message counters.
type ProcessorWithContext ¶
processor with passed in context to catch possible system stop signal
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is for timing events
type TimerStats ¶
func ReadTimers ¶
func ReadTimers() []TimerStats