Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/redis] Set start timestamp uniformly for gauge and sum metrics #6941

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -9,6 +9,7 @@
- `datadogexporter`: Add compatibility with ECS Fargate semantic conventions (#6670)
- `k8s_observer`: discover k8s.node endpoints (#6820)
- `redisreceiver`: Add missing description fields to keyspace metrics (#6940)
- `redisreceiver`: Set start timestamp uniformly for gauge and sum metrics (#6941)
- `kafkaexporter`: Allow controlling Kafka acknowledgment behaviour (#6301)

## 🛑 Breaking changes 🛑
Expand Down
4 changes: 2 additions & 2 deletions receiver/redisreceiver/pdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func initIntMetric(m *redisMetric, value int64, t *timeBundle, dest pdata.Metric
sum.SetIsMonotonic(m.isMonotonic)
sum.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative)
pt = sum.DataPoints().AppendEmpty()
pt.SetStartTimestamp(pdata.NewTimestampFromTime(t.serverStart))
}
pt.SetIntVal(value)
pt.SetStartTimestamp(pdata.NewTimestampFromTime(t.serverStart))
pt.SetTimestamp(pdata.NewTimestampFromTime(t.current))
pdata.NewAttributeMapFromMap(m.labels).CopyTo(pt.Attributes())
}
Expand All @@ -87,9 +87,9 @@ func initDoubleMetric(m *redisMetric, value float64, t *timeBundle, dest pdata.M
sum.SetIsMonotonic(m.isMonotonic)
sum.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative)
pt = sum.DataPoints().AppendEmpty()
pt.SetStartTimestamp(pdata.NewTimestampFromTime(t.serverStart))
}
pt.SetDoubleVal(value)
pt.SetStartTimestamp(pdata.NewTimestampFromTime(t.serverStart))
pt.SetTimestamp(pdata.NewTimestampFromTime(t.current))
pdata.NewAttributeMapFromMap(m.labels).CopyTo(pt.Attributes())
}
Expand Down
4 changes: 2 additions & 2 deletions receiver/redisreceiver/pdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ func TestNewPDM(t *testing.T) {

pdm := pdata.NewMetric()
initIntMetric(&redisMetric{pdType: pdata.MetricDataTypeGauge}, 0, tb, pdm)
assert.Equal(t, pdata.Timestamp(0), pdm.Gauge().DataPoints().At(0).StartTimestamp())
assert.Equal(t, serverStartTime, pdm.Gauge().DataPoints().At(0).StartTimestamp())

pdm = pdata.NewMetric()
initIntMetric(&redisMetric{pdType: pdata.MetricDataTypeSum}, 0, tb, pdm)
assert.Equal(t, serverStartTime, pdm.Sum().DataPoints().At(0).StartTimestamp())

pdm = pdata.NewMetric()
initDoubleMetric(&redisMetric{pdType: pdata.MetricDataTypeGauge}, 0, tb, pdm)
assert.Equal(t, pdata.Timestamp(0), pdm.Gauge().DataPoints().At(0).StartTimestamp())
assert.Equal(t, serverStartTime, pdm.Gauge().DataPoints().At(0).StartTimestamp())

pdm = pdata.NewMetric()
initDoubleMetric(&redisMetric{pdType: pdata.MetricDataTypeSum}, 0, tb, pdm)
Expand Down