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:
2020-12-23 13:27:17 +05:00
parent de5b55da43
commit 529113a41a
10 changed files with 210 additions and 54 deletions

34
internal/models/metric.go Normal file
View 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
}

View 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
}