Documentation
¶
Index ¶
- Variables
- func CollectParamsOnReqEnd(params map[string]interface{}, statusCode int) map[string]interface{}
- func DefaultReqParams(endpointName string) map[string]interface{}
- func UpdateMetricsOnReqEnd(params map[string]interface{})
- type AppMetric
- type ErrorRatePerEndpoint
- type Reporter
- type ReqPerEndpoint
- type ResponseTimePerEndpoint
- type StandardMetric
Constants ¶
This section is empty.
Variables ¶
var ( // Log is a logger used in the package Log *log.Logger // NewRelic GUID for creating the NewRelic plugin Guid string )
Functions ¶
func CollectParamsOnReqEnd ¶
CollectParamsOnReqEnd populates params map with additional data available when the request processing is already done e.g. http response status code
func DefaultReqParams ¶
DefaultReqParams creates and populates request parameters map to be used by default metrics Called in the beginning of each request
func UpdateMetricsOnReqEnd ¶
func UpdateMetricsOnReqEnd(params map[string]interface{})
UpdateMetricsOnReqEnd updates all defined metrics in the end of each request
Types ¶
type AppMetric ¶
type AppMetric interface {
// Update all the values that will be reported (or be used in calculation).
// For http metrics called on every request (for example in gin middleware)
Update(params map[string]interface{}) error
// ValueMap extracts all values from AppMetric data structures
// to be reported to NewRelic.
// A single AppMetric can produce multiple metrics as perceived by NewRelic
// Consult NewRelic plugin API naming guidelines
// before creating a new metric.
//
// Note that this function is also responsible for clearing the values
// after they have been reported.
ValueMap() map[string]float32
}
AppMetric is an interface for metrics reported to NewRelic
type ErrorRatePerEndpoint ¶
type ErrorRatePerEndpoint struct {
*StandardMetric
// contains filtered or unexported fields
}
ErrorRatePerEndpoint holds the percentage of error requests per endpoint
func NewErrorRatePerEndpoint ¶
func NewErrorRatePerEndpoint() *ErrorRatePerEndpoint
NewErrorRatePerEndpoint creates new POEPerEndpoint metric
func (*ErrorRatePerEndpoint) Update ¶
func (m *ErrorRatePerEndpoint) Update(params map[string]interface{}) error
Update the metric values
func (*ErrorRatePerEndpoint) ValueMap ¶
func (m *ErrorRatePerEndpoint) ValueMap() map[string]float32
ValueMap extract all the metrics to be reported
type Reporter ¶
type Reporter struct {
Metrics []AppMetric
// contains filtered or unexported fields
}
Reporter keeps track of the app metrics and sends them to NewRelic
var ( // Engine reports metrics to NewRelic Engine *Reporter )
func InitDefaultReporter ¶
InitDefaultReporter creates a new reporter and adds standard metrics
func NewReporter ¶
NewReporter creates a new Reporter
type ReqPerEndpoint ¶
type ReqPerEndpoint struct {
*StandardMetric
}
ReqPerEndpoint holds number of requests per endpoint
func NewReqPerEndpoint ¶
func NewReqPerEndpoint() *ReqPerEndpoint
NewReqPerEndpoint creates new ReqPerEndpoint metric
func (*ReqPerEndpoint) Update ¶
func (m *ReqPerEndpoint) Update(params map[string]interface{}) error
Update the metric values
func (*ReqPerEndpoint) ValueMap ¶
func (m *ReqPerEndpoint) ValueMap() map[string]float32
ValueMap extract all the metrics to be reported
type ResponseTimePerEndpoint ¶
type ResponseTimePerEndpoint struct {
*StandardMetric
// contains filtered or unexported fields
}
ResponseTimePerEndpoint tracks the response time per endpoint
func NewResponseTimePerEndpoint ¶
func NewResponseTimePerEndpoint() *ResponseTimePerEndpoint
NewResponseTimePerEndpoint creates new ResponseTimePerEndpoint metric
func (*ResponseTimePerEndpoint) Update ¶
func (m *ResponseTimePerEndpoint) Update(params map[string]interface{}) error
Update the metric values
func (*ResponseTimePerEndpoint) ValueMap ¶
func (m *ResponseTimePerEndpoint) ValueMap() map[string]float32
ValueMap extract all the metrics to be reported
type StandardMetric ¶
type StandardMetric struct {
// contains filtered or unexported fields
}
StandardMetric is a base for metrics dealing with endpoints
