Skip to content

Commit

Permalink
Fix tag propagation for temporal functions (#1307)
Browse files Browse the repository at this point in the history
Temporal functions don't properly propagate series tags (thanks to @arnikola for suggesting this as the bug!).

For instance, given series:

```
coordinator_engine_datapoints{type="fetched"} 1386
coordinator_engine_datapoints{type="generated"} 104
```

a query like increase(coordinator_engine_datapoints[5s]) will return

```
{
  "__name__": "coordinator_engine_datapoints",
  "instance": "host.docker.internal:7203",
  "job": "coordinator",
  "role": "remote"
}
{
  "__name__": "coordinator_engine_datapoints",
  "instance": "host.docker.internal:7203",
  "job": "coordinator",
  "role": "remote"
}
```

dropping tags. Querying the same range without increase gives all tags, as expected.

Fix is simple; we weren't copying tags into the new block's SeriesMetas; now we do.
  • Loading branch information
andrewmains12 committed Jan 22, 2019
1 parent bcf5dd1 commit 4cc991b
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 239 deletions.
8 changes: 7 additions & 1 deletion src/query/functions/temporal/base.go
Expand Up @@ -254,10 +254,16 @@ func (c *baseNode) processSingleRequest(request processRequest) error {
bounds := seriesIter.Meta().Bounds

seriesMeta := seriesIter.SeriesMeta()

// rename series to exclude their __name__ tag
// TODO: why do we do this?
resultSeriesMeta := make([]block.SeriesMeta, len(seriesMeta))
for i, m := range seriesMeta {
tags := m.Tags.WithoutName()
resultSeriesMeta[i].Name = tags.ID()
resultSeriesMeta[i] = block.SeriesMeta{
Name: tags.ID(),
Tags: tags,
}
}

builder, err := c.controller.BlockBuilder(seriesIter.Meta(), resultSeriesMeta)
Expand Down

0 comments on commit 4cc991b

Please sign in to comment.