MCPcopy Create free account
hub / github.com/cortexproject/cortex / GenerateSeriesWithSamples

Function GenerateSeriesWithSamples

integration/e2e/util.go:192–225  ·  view source on GitHub ↗
(
	name string,
	startTime time.Time,
	scrapeInterval time.Duration,
	startValue int,
	numSamples int,
	additionalLabels ...prompb.Label,
)

Source from the content-addressed store, hash-verified

190}
191
192func GenerateSeriesWithSamples(
193 name string,
194 startTime time.Time,
195 scrapeInterval time.Duration,
196 startValue int,
197 numSamples int,
198 additionalLabels ...prompb.Label,
199) (series prompb.TimeSeries) {
200 tsMillis := TimeToMilliseconds(startTime)
201 durMillis := scrapeInterval.Milliseconds()
202
203 lbls := append(
204 []prompb.Label{
205 {Name: labels.MetricName, Value: name},
206 },
207 additionalLabels...,
208 )
209
210 startTMillis := tsMillis
211 samples := make([]prompb.Sample, numSamples)
212 for i := range numSamples {
213 scrapeJitter := rand.Int63n(10) + 1 // add a jitter to simulate real-world scenarios, refer to: https://github.com/prometheus/prometheus/issues/13213
214 samples[i] = prompb.Sample{
215 Timestamp: startTMillis + scrapeJitter,
216 Value: float64(i + startValue),
217 }
218 startTMillis += durMillis
219 }
220
221 return prompb.TimeSeries{
222 Labels: lbls,
223 Samples: samples,
224 }
225}
226
227// GetTempDirectory creates a temporary directory for shared integration
228// test files, either in the working directory or a directory referenced by

Calls 1

TimeToMillisecondsFunction · 0.85