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

Function generateData

pkg/querier/tripperware/query_test.go:117–195  ·  view source on GitHub ↗
(timeseries, datapoints int)

Source from the content-addressed store, hash-verified

115}
116
117func generateData(timeseries, datapoints int) (floatMatrix, histogramMatrix []*SampleStream) {
118 for i := range timeseries {
119 lset := labels.FromMap(map[string]string{
120 model.MetricNameLabel: "timeseries_" + strconv.Itoa(i),
121 "foo": "bar",
122 })
123 now := model.Time(1677587274055).Time()
124 floats := make([]cortexpb.Sample, datapoints)
125 histograms := make([]SampleHistogramPair, datapoints)
126
127 for x := datapoints; x > 0; x-- {
128 f := float64(x)
129 floats[x-1] = cortexpb.Sample{
130 // Set the time back assuming a 15s interval. Since this is used for
131 // Marshal/Unmarshal testing the actual interval doesn't matter.
132 TimestampMs: util.TimeToMillis(now.Add(time.Second * -15 * time.Duration(x))),
133 Value: f,
134 }
135 histograms[x-1] = SampleHistogramPair{
136 TimestampMs: util.TimeToMillis(now.Add(time.Second * -15 * time.Duration(x))),
137 Histogram: SampleHistogram{
138 Count: 13.5 * f,
139 Sum: .1 * f,
140 Buckets: []*HistogramBucket{
141 {
142 Boundaries: 1,
143 Lower: -4870.992343051145,
144 Upper: -4466.7196729968955,
145 Count: 1 * f,
146 },
147 {
148 Boundaries: 1,
149 Lower: -861.0779292198035,
150 Upper: -789.6119426088657,
151 Count: 2 * f,
152 },
153 {
154 Boundaries: 1,
155 Lower: -558.3399591246119,
156 Upper: -512,
157 Count: 3 * f,
158 },
159 {
160 Boundaries: 0,
161 Lower: 2048,
162 Upper: 2233.3598364984477,
163 Count: 1.5 * f,
164 },
165 {
166 Boundaries: 0,
167 Lower: 2896.3093757400984,
168 Upper: 3158.4477704354626,
169 Count: 2.5 * f,
170 },
171 {
172 Boundaries: 0,
173 Lower: 4466.7196729968955,
174 Upper: 4870.992343051145,

Callers 1

Calls 3

TimeToMillisFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected