Merge pull request #11212 from influxdata/fix/scraper-types

fix(scraper): remove enriched type label
pull/11216/head
Chris Goller 2019-01-17 10:33:47 -06:00 committed by GitHub
commit 4f1b8ad846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -37,9 +37,7 @@ func (ms MetricsSlice) Points() (models.Points, error) {
if err != nil {
return ps, err
}
if m.Type.Valid() {
point.AddTag("type", m.Type.String())
}
ps[mi] = point
}
return ps, nil
@ -54,13 +52,12 @@ func (ms MetricsSlice) Reader() (io.Reader, error) {
if err != nil {
return nil, err
}
if m.Type.Valid() {
point.AddTag("type", m.Type.String())
}
_, err = buf.WriteString(point.String())
if err != nil {
return nil, err
}
if mi < len(ms)-1 && len(ms) > 1 {
_, err = buf.WriteString("\n")
if err != nil {

View File

@ -30,6 +30,23 @@ func TestMetricsReader(t *testing.T) {
},
wants: "cpu_load_short value=0.64 1422568543702900257",
},
{
name: "gauge with type label produces lineprotocol with one type",
ms: []Metrics{
{
Name: "error_metric",
Tags: map[string]string{
"type": "gauge",
},
Fields: map[string]interface{}{
"value": "yes",
},
Type: MetricTypeGauge,
Timestamp: time.Unix(0, 1422568543702900257),
},
},
wants: `error_metric,type=gauge value="yes" 1422568543702900257`,
},
{
name: "single regular metrics",
ms: []Metrics{
@ -46,7 +63,7 @@ func TestMetricsReader(t *testing.T) {
Timestamp: time.Unix(0, 1422568543702900257),
},
},
wants: "cpu_load_short,host=server01,region=us-west,type=GAUGE value=0.64 1422568543702900257",
wants: "cpu_load_short,host=server01,region=us-west value=0.64 1422568543702900257",
},
{
name: "multiple value only",