Documentation ¶
Index ¶
- type CounterMetric
- func (msg *CounterMetric) AddValue(count int64, labels ...string)
- func (msg *CounterMetric) RemoveLogging(labels ...string)
- func (msg *CounterMetric) SetValue(count int64, labels ...string)
- func (msg *CounterMetric) SubValue(count int64, labels ...string)
- func (msg *CounterMetric) UpdateTime(elapsed int64, labels ...string)
- type CustomLogger
- func (l *CustomLogger) GetLogLevel() LogLevels
- func (l *CustomLogger) LogDebug(str string)
- func (l *CustomLogger) LogDebugf(str string, args ...interface{})
- func (l *CustomLogger) LogError(str string, err error)
- func (l *CustomLogger) LogErrorInterface(v ...interface{})
- func (l *CustomLogger) LogErrorMessage(str string, err error, pairs ...Pair)
- func (l *CustomLogger) LogErrorWithoutError(str string)
- func (l *CustomLogger) LogErrorWithoutErrorf(str string, args ...interface{})
- func (l *CustomLogger) LogInfo(str string)
- func (l *CustomLogger) LogInfoMessage(str string, pairs ...Pair)
- func (l *CustomLogger) LogInfof(str string, args ...interface{})
- func (l *CustomLogger) LogMessage(message string)
- func (l *CustomLogger) LogMessageWithExtras(message string, level LogLevels, pairs ...Pair)
- func (l *CustomLogger) LogMessagef(message string, args ...interface{})
- func (l *CustomLogger) LogWarning(str string)
- func (l *CustomLogger) LogWarningMessage(str string, pairs ...Pair)
- func (l *CustomLogger) LogWarningf(str string, args ...interface{})
- func (l *CustomLogger) Tic(s string) (string, time.Time)
- func (l *CustomLogger) Toc(message string, startTime time.Time)
- type GaugeMetric
- func (msg *GaugeMetric) AddValue(count int64, labels ...string)
- func (msg *GaugeMetric) RemoveLogging(labels ...string)
- func (msg *GaugeMetric) SetValue(count int64, labels ...string)
- func (msg *GaugeMetric) SubValue(count int64, labels ...string)
- func (msg *GaugeMetric) UpdateTime(elapsed int64, labels ...string)
- type HistogramMetric
- func (msg *HistogramMetric) AddValue(count int64, labels ...string)
- func (msg *HistogramMetric) RemoveLogging(labels ...string)
- func (msg *HistogramMetric) SetValue(count int64, labels ...string)
- func (msg *HistogramMetric) SubValue(count int64, labels ...string)
- func (msg *HistogramMetric) UpdateTime(elapsed int64, labels ...string)
- type IMetricVec
- type IMultiLogger
- type LogLevels
- type Option
- func ConsolePrintEnabled(flag bool) Option
- func DisableGraylog(flag bool) Option
- func GraylogFacility(facility string) Option
- func GraylogHost(hostName string) Option
- func GraylogPort(portNumber int) Option
- func SetK8sNamespace(k8sNamespace string) Option
- func SetLogLevel(level string) Option
- func TimeLoggingEnabled(flag bool) Option
- type Pair
- type RateLatencyLogger
- func (mgl *RateLatencyLogger) AddNewMetric(messageIdentifier string, newMessage IMetricVec)
- func (mgl *RateLatencyLogger) IncVal(value int64, identifier string, labels ...string)
- func (mgl *RateLatencyLogger) SetVal(value int64, identifier string, labels ...string)
- func (mgl *RateLatencyLogger) SubVal(value int64, identifier string, labels ...string)
- func (mgl *RateLatencyLogger) Tic() time.Time
- func (mgl *RateLatencyLogger) Toc(start time.Time, identifier string, labels ...string)
- type RateLatencyOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CounterMetric ¶
type CounterMetric struct {
// contains filtered or unexported fields
}
CounterMetric : Default histogram message type implementing IMetricVec
func NewCounterMetric ¶
func NewCounterMetric(counter *prometheus.CounterVec, logger *CustomLogger) *CounterMetric
NewCounterMetric creates a new histrogram message and registers it to prometheus
func (*CounterMetric) AddValue ¶
func (msg *CounterMetric) AddValue(count int64, labels ...string)
AddValue will increment the counter by value
func (*CounterMetric) RemoveLogging ¶
func (msg *CounterMetric) RemoveLogging(labels ...string)
RemoveLogging will stop logging for specific labels
func (*CounterMetric) SetValue ¶
func (msg *CounterMetric) SetValue(count int64, labels ...string)
SetValue will not do anything. It is not allowed in counters
func (*CounterMetric) SubValue ¶
func (msg *CounterMetric) SubValue(count int64, labels ...string)
SubValue will not do anything. It is not allowed in counters
func (*CounterMetric) UpdateTime ¶
func (msg *CounterMetric) UpdateTime(elapsed int64, labels ...string)
UpdateTime is a do nothing operation for counter metric
type CustomLogger ¶
type CustomLogger struct {
// contains filtered or unexported fields
}
CustomLogger is a graylog logger for golang
func NewLogger ¶
func NewLogger(LoggerOptions ...Option) *CustomLogger
NewLogger : returns a new logger. When no options are given, it returns an error logger With graylog logging as default to a port 11100 which is not in use. So it is prety much useless. Please provide graylog host and port at the very least.
func (*CustomLogger) GetLogLevel ¶
func (l *CustomLogger) GetLogLevel() LogLevels
GetLogLevel is used to get the current Log level
func (*CustomLogger) LogDebug ¶
func (l *CustomLogger) LogDebug(str string)
LogDebug is used to send debug messages
func (*CustomLogger) LogDebugf ¶
func (l *CustomLogger) LogDebugf(str string, args ...interface{})
LogDebugf is used to send debug messages
func (*CustomLogger) LogError ¶
func (l *CustomLogger) LogError(str string, err error)
LogError is used to send errors and a message along with the error
func (*CustomLogger) LogErrorInterface ¶
func (l *CustomLogger) LogErrorInterface(v ...interface{})
LogErrorInterface is used to send errors
func (*CustomLogger) LogErrorMessage ¶
func (l *CustomLogger) LogErrorMessage(str string, err error, pairs ...Pair)
LogErrorMessage is used to send extra fields to graylog along with the error
func (*CustomLogger) LogErrorWithoutError ¶
func (l *CustomLogger) LogErrorWithoutError(str string)
LogErrorWithoutError is used to send only a message and not an error
func (*CustomLogger) LogErrorWithoutErrorf ¶
func (l *CustomLogger) LogErrorWithoutErrorf(str string, args ...interface{})
LogErrorWithoutErrorf is used to send only a message and not an error
func (*CustomLogger) LogInfo ¶
func (l *CustomLogger) LogInfo(str string)
LogInfo is used to send info messages
func (*CustomLogger) LogInfoMessage ¶
func (l *CustomLogger) LogInfoMessage(str string, pairs ...Pair)
LogInfoMessage is used to send extra fields to graylog
func (*CustomLogger) LogInfof ¶
func (l *CustomLogger) LogInfof(str string, args ...interface{})
LogInfof is used to send formatted info messages
func (*CustomLogger) LogMessage ¶
func (l *CustomLogger) LogMessage(message string)
LogMessage is used to log plain message
func (*CustomLogger) LogMessageWithExtras ¶
func (l *CustomLogger) LogMessageWithExtras(message string, level LogLevels, pairs ...Pair)
func (*CustomLogger) LogMessagef ¶
func (l *CustomLogger) LogMessagef(message string, args ...interface{})
LogMessagef is used to log plain message
func (*CustomLogger) LogWarning ¶
func (l *CustomLogger) LogWarning(str string)
LogWarning is used to send warning messages
func (*CustomLogger) LogWarningMessage ¶
func (l *CustomLogger) LogWarningMessage(str string, pairs ...Pair)
LogWarningMessage is used to send warning messages along with extra fields to GrayLog
func (*CustomLogger) LogWarningf ¶
func (l *CustomLogger) LogWarningf(str string, args ...interface{})
LogWarningf is used to send warning messages
func (*CustomLogger) Tic ¶
func (l *CustomLogger) Tic(s string) (string, time.Time)
Tic is used to log time taken by a function. It should be used along with Toc function Tic will take an input as a string message (It can be the name of the function) And will return time and the message. For full used see the Toc funtion
func (*CustomLogger) Toc ¶
func (l *CustomLogger) Toc(message string, startTime time.Time)
Toc will log the time taken by the funtion. Its input is the output of the Tic function Here is an example code block for using Tic and Toc function
defer Toc(Tic("FunctionName"))
This will the first line of the function
type GaugeMetric ¶
type GaugeMetric struct {
// contains filtered or unexported fields
}
GaugeMetric : Default Gauge message type implementing IMetricVec
func NewGaugeMetric ¶
func NewGaugeMetric(counter *prometheus.GaugeVec, logger *CustomLogger) *GaugeMetric
NewGaugeMetric creates a new gauge message and registers it to prometheus
func (*GaugeMetric) AddValue ¶
func (msg *GaugeMetric) AddValue(count int64, labels ...string)
AddValue will increment the counter by value
func (*GaugeMetric) RemoveLogging ¶
func (msg *GaugeMetric) RemoveLogging(labels ...string)
RemoveLogging will stop logging for specific labels
func (*GaugeMetric) SetValue ¶
func (msg *GaugeMetric) SetValue(count int64, labels ...string)
SetValue will set the counter to that value
func (*GaugeMetric) SubValue ¶
func (msg *GaugeMetric) SubValue(count int64, labels ...string)
SubValue will decrement the counter by value
func (*GaugeMetric) UpdateTime ¶
func (msg *GaugeMetric) UpdateTime(elapsed int64, labels ...string)
UpdateTime is a do nothing operation for counter metric
type HistogramMetric ¶
type HistogramMetric struct {
// contains filtered or unexported fields
}
HistogramMetric : Default histogram message type implementing IMetricVec
func NewHistogramMetric ¶
func NewHistogramMetric(hist *prometheus.HistogramVec, logger *CustomLogger) *HistogramMetric
NewHistogramMetric creates a new histrogram message and registers it to prometheus
func (*HistogramMetric) AddValue ¶
func (msg *HistogramMetric) AddValue(count int64, labels ...string)
AddValue is a do nothing function for histogram
func (*HistogramMetric) RemoveLogging ¶
func (msg *HistogramMetric) RemoveLogging(labels ...string)
RemoveLogging will stop logging for specific labels
func (*HistogramMetric) SetValue ¶
func (msg *HistogramMetric) SetValue(count int64, labels ...string)
SetValue is a do nothing function for histogram
func (*HistogramMetric) SubValue ¶
func (msg *HistogramMetric) SubValue(count int64, labels ...string)
SubValue is a do nothing function for histogram
func (*HistogramMetric) UpdateTime ¶
func (msg *HistogramMetric) UpdateTime(elapsed int64, labels ...string)
UpdateTime the message with calculated latency
type IMetricVec ¶
type IMetricVec interface { UpdateTime(int64, ...string) //Method to count increments or gauges AddValue(int64, ...string) // Method to subtract from the counter SubValue(int64, ...string) // Method to set the counter SetValue(int64, ...string) // Method to Remove the label from the metric RemoveLogging(...string) }
IMetricVec : Interface to implement for Message type
type IMultiLogger ¶
type IMultiLogger interface { // To measure time elapsed between any two points in the code, // Start the time logger by Tic(MessageDesc) and end the time logger by calling Toc(MessageDesc,time) Tic() time.Time Toc(time.Time, string, ...string) IncVal(int64, string, ...string) SubVal(int64, string, ...string) SetVal(int64, string, ...string) AddNewMetric(string, IMetricVec) }
IMultiLogger : Interface for Multi message logger
func NewRateLatencyLogger ¶
func NewRateLatencyLogger(options ...RateLatencyOption) IMultiLogger
NewRateLatencyLogger : returns a new RateLatencyLogger. When no options are given, it returns a RateLatencyLogger with default settings. Default logger is default custom logger.
type LogLevels ¶
type LogLevels uint32
LogLevels are the log levels for logging
const ( // ERROR : All errors will be logged with this level ERROR LogLevels = 0 // WARN : All important events should be logged with a warn WARN LogLevels = 1 // INFO : All events other than the important ones to be logged here INFO LogLevels = 2 // DEBUG : This is for debug purposes only. Never use it on staging and production DEBUG LogLevels = 3 )
type Option ¶
type Option func(l *CustomLogger)
Option sets a parameter for the Logger
func ConsolePrintEnabled ¶
ConsolePrintEnabled enables console output for logging. To be used only for development.
func DisableGraylog ¶
DisableGraylog disables graylog logging. Defaults to false If graylog is disabled console logging will be enabled by default
func GraylogFacility ¶
GraylogFacility sets the graylog facility for the logger. Default is "ErrorLogger"
func GraylogHost ¶
GraylogHost sets the graylog host for the logger. Default is 127.0.0.1
func GraylogPort ¶
GraylogPort sets the graylog port for the logger. Default is 11100
func SetK8sNamespace ¶ added in v1.1.0
K8sNamespace sets the graylog k8sNamespace for the logger. Default is "dev" This option will have no effect if env variable K8S_NAMESPACE is set
func SetLogLevel ¶
SetLogLevel sets the logger level Possible values are ERROR, WARN, INFO, DEBUG. Default is ERROR
func TimeLoggingEnabled ¶
TimeLoggingEnabled enables logging of time (The use of tic toc functions). This can be used in functions and then disabled here when there is no need.
type RateLatencyLogger ¶
type RateLatencyLogger struct {
// contains filtered or unexported fields
}
RateLatencyLogger : Logger that tracks multiple messages & prints to console
func (*RateLatencyLogger) AddNewMetric ¶
func (mgl *RateLatencyLogger) AddNewMetric(messageIdentifier string, newMessage IMetricVec)
AddNewMetric sets New message initialisation function
func (*RateLatencyLogger) IncVal ¶
func (mgl *RateLatencyLogger) IncVal(value int64, identifier string, labels ...string)
IncVal is used for counters and gauges
func (*RateLatencyLogger) SetVal ¶
func (mgl *RateLatencyLogger) SetVal(value int64, identifier string, labels ...string)
SetVal is used for counters and gauges
type RateLatencyOption ¶
type RateLatencyOption func(rl *RateLatencyLogger)
RateLatencyOption sets a parameter for the RateLatencyLogger
func SetLogger ¶
func SetLogger(logger *CustomLogger) RateLatencyOption
SetLogger sets the output logger. Default is stderr