Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ storage:
* [CHANGE] Ignore context canceled errors in the queriers [#2440](https://github.com/grafana/tempo/pull/2440) (@joe-elliott)
* [CHANGE] Start flush queue worker after wal replay and block rediscovery [#2456](https://github.com/grafana/tempo/pull/2456) (@ie-pham)
* [CHANGE] Update Go to 1.20.4 to match GET [#2486](https://github.com/grafana/tempo/pull/2486) (@ie-pham)
* [BUGFIX] Fix issue where metrics-generator was setting wrong labels for traces_target_info [#2546](https://github.com/grafana/tempo/pull/2546) (@ie-pham)

## v2.1.1 / 2023-04-28
* [BUGFIX] Fix issue where Tempo sometimes flips booleans from false->true at storage time. [#2400](https://github.com/grafana/tempo/issues/2400) (@joe-elliott)
Expand Down
26 changes: 11 additions & 15 deletions modules/generator/registry/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,27 @@ func (g *gauge) collectMetrics(appender storage.Appender, timeMs int64, external

activeSeries = len(g.series)

labelsCount := 0
if activeSeries > 0 && g.series[0] != nil {
labelsCount = len(g.series[0].labels.names)
}
lbls := make(labels.Labels, 1+len(externalLabels)+labelsCount)
lb := labels.NewBuilder(lbls)

// set metric name
lb.Set(labels.MetricName, g.metricName)
// set external labels
for name, value := range externalLabels {
lb.Set(name, value)
}

for _, s := range g.series {
t := time.UnixMilli(timeMs)
lbls := make(labels.Labels, 1+len(externalLabels)+len(s.labels.names))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to keep the allocations outside of the loop. I think I saw a Reset() method on the lb object that might empty this out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

lb := labels.NewBuilder(lbls)

// set metric name
lb.Set(labels.MetricName, g.metricName)
// set external labels
for name, value := range externalLabels {
lb.Set(name, value)
}

// set series-specific labels
for i, name := range s.labels.names {
lb.Set(name, s.labels.values[i])
}

_, err = appender.Append(0, lb.Labels(nil), t.UnixMilli(), s.value.Load())
if err != nil {
return
}

// TODO support exemplars
}

Expand Down