Add more debug output and fixed metrics name composing.

This commit is contained in:
2020-12-23 22:12:25 +05:00
parent cdfa948b7d
commit 9410522dd5
2 changed files with 11 additions and 0 deletions

View File

@@ -29,12 +29,17 @@ func (a *Application) parse(body string) map[string]models.Metric {
a.logger.Debugln("Analyzing line:", line)
name = a.getMetricName(line)
a.logger.Debugln("Got metric name:", name)
metric, found := data[name]
if !found {
a.logger.Debugln("Metric wasn't yet created, creating new structure")
metric = models.NewMetric(name, "", "", nil)
}
a.logger.Debugf("Got metric to use: %+v\n", metric)
// If line is commented - then we have something about metric's description
// or type. It should be handled in special way - these metric will became
// "pseudometric" which will be used as template for next iterations. For
@@ -65,12 +70,15 @@ func (a *Application) parse(body string) map[string]models.Metric {
// structure copying.
if strings.Contains(line, "{") {
newMetric := metric
newMetric.Name = newMetric.BaseName
params = a.getParametersForPrometheusMetric(line)
for _, param := range params {
newMetric.Name += "/" + param
}
newMetric.Params = params
metric = newMetric
data[metric.Name] = metric
}