Metrics data is stored as structure, HTTP requests logging, got rid of context.
Metrics data now stored as structures. This is a first step for autodiscovery helping for NMSes. HTTP requests now logged. Got rid of context.Context for getting metric data in applications because context.Context is useless here.
This commit is contained in:
34
internal/models/metric.go
Normal file
34
internal/models/metric.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package models
|
||||
|
||||
// Metric is a generic metric structure.
|
||||
type Metric struct {
|
||||
// Metric name.
|
||||
name string
|
||||
// HELP data, if present.
|
||||
description string
|
||||
// Additional parameters, data inside "{}".
|
||||
params []string
|
||||
// Metric value.
|
||||
value string
|
||||
}
|
||||
|
||||
// NewMetric creates new structure for storing single metric data.
|
||||
func NewMetric(name, description string, params []string) Metric {
|
||||
m := Metric{
|
||||
name: name,
|
||||
description: description,
|
||||
params: params,
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// GetValue returns metric's value.
|
||||
func (m *Metric) GetValue() string {
|
||||
return m.value
|
||||
}
|
||||
|
||||
// SetValue sets value for metric.
|
||||
func (m *Metric) SetValue(value string) {
|
||||
m.value = value
|
||||
}
|
9
internal/models/request_info.go
Normal file
9
internal/models/request_info.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package models
|
||||
|
||||
// RequestInfo is a parsed request information to throw into application's handler.
|
||||
type RequestInfo struct {
|
||||
ApiVersion int
|
||||
Application string
|
||||
Metric string
|
||||
RequestType string
|
||||
}
|
Reference in New Issue
Block a user