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

Add support for diffs of MetricData #1405

Merged
merged 1 commit into from
Jul 22, 2020
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
16 changes: 11 additions & 5 deletions internal/goldendataset/metric_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type MetricCfg struct {
NumResourceAttrs int
// The number of ResourceMetrics for the single MetricData generated
NumResourceMetrics int
// The base value for each point
PtVal int
// The start time for each point
StartTime uint64
// The duration of the steps between each generated point starting at StartTime
Expand All @@ -55,6 +57,7 @@ func DefaultCfg() MetricCfg {
NumPts: 1,
NumResourceAttrs: 1,
NumResourceMetrics: 1,
PtVal: 1,
StartTime: 940000000000000000,
StepSize: 42,
}
Expand Down Expand Up @@ -128,7 +131,7 @@ func populateIntPoints(cfg MetricCfg, metric pdata.Metric) {
pt := pts.At(i)
pt.SetStartTime(pdata.TimestampUnixNano(cfg.StartTime))
pt.SetTimestamp(getTimestamp(cfg.StartTime, cfg.StepSize, i))
pt.SetValue(1 + int64(i))
pt.SetValue(int64(cfg.PtVal + i))
populatePtLabels(cfg, pt.LabelsMap())
}
}
Expand All @@ -140,7 +143,7 @@ func populateDblPoints(cfg MetricCfg, metric pdata.Metric) {
pt := pts.At(i)
pt.SetStartTime(pdata.TimestampUnixNano(cfg.StartTime))
pt.SetTimestamp(getTimestamp(cfg.StartTime, cfg.StepSize, i))
pt.SetValue(float64(1 + i))
pt.SetValue(float64(cfg.PtVal + i))
populatePtLabels(cfg, pt.LabelsMap())
}
}
Expand All @@ -156,8 +159,9 @@ func populateHistogramPoints(cfg MetricCfg, metric pdata.Metric) {
populatePtLabels(cfg, pt.LabelsMap())
setHistogramBounds(pt, 1, 2, 3, 4, 5)
addHistogramVal(pt, 1, ts)
addHistogramVal(pt, 3, ts)
addHistogramVal(pt, 3, ts)
for i := 0; i < cfg.PtVal; i++ {
addHistogramVal(pt, 3, ts)
}
addHistogramVal(pt, 5, ts)
}
}
Expand Down Expand Up @@ -195,7 +199,9 @@ func populateSummaryPoints(cfg MetricCfg, metric pdata.Metric) {
pt.SetTimestamp(getTimestamp(cfg.StartTime, cfg.StepSize, i))
setSummaryPercentiles(pt, 0, 50, 95)
addSummaryValue(pt, 55, 0)
addSummaryValue(pt, 70, 1)
for i := 0; i < cfg.PtVal; i++ {
addSummaryValue(pt, 70, 1)
}
addSummaryValue(pt, 90, 2)
populatePtLabels(cfg, pt.LabelsMap())
}
Expand Down
1 change: 1 addition & 0 deletions internal/goldendataset/metric_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestHistogramFunctions(t *testing.T) {
func TestGenHistogram(t *testing.T) {
cfg := DefaultCfg()
cfg.MetricDescriptorType = pdata.MetricTypeHistogram
cfg.PtVal = 2
md := MetricDataFromCfg(cfg)
pts := getMetric(md).HistogramDataPoints()
pt := pts.At(0)
Expand Down
Loading