generateTestTimeSeries creates test time series data for benchmarking nolint:gosec // G115
(seriesCount, samplesCount, exemplarCount int, start, end uint64)
| 3190 | // generateTestTimeSeries creates test time series data for benchmarking |
| 3191 | // nolint:gosec // G115 |
| 3192 | func generateTestTimeSeries(seriesCount, samplesCount, exemplarCount int, start, end uint64) []*tempopb.TimeSeries { |
| 3193 | result := make([]*tempopb.TimeSeries, seriesCount) |
| 3194 | |
| 3195 | timeRange := end - start |
| 3196 | |
| 3197 | for i := 0; i < seriesCount; i++ { |
| 3198 | // Create unique labels for each series |
| 3199 | labels := []commonv1proto.KeyValue{ |
| 3200 | { |
| 3201 | Key: "service", |
| 3202 | Value: &commonv1proto.AnyValue{ |
| 3203 | Value: &commonv1proto.AnyValue_StringValue{ |
| 3204 | StringValue: "service-" + fmt.Sprintf("%d", i), |
| 3205 | }, |
| 3206 | }, |
| 3207 | }, |
| 3208 | { |
| 3209 | Key: internalLabelBucket, |
| 3210 | Value: &commonv1proto.AnyValue{ |
| 3211 | Value: &commonv1proto.AnyValue_DoubleValue{ |
| 3212 | DoubleValue: math.Pow(2, float64(i%20)), // Power of 2 as bucket |
| 3213 | }, |
| 3214 | }, |
| 3215 | }, |
| 3216 | } |
| 3217 | |
| 3218 | samples := make([]tempopb.Sample, samplesCount) |
| 3219 | for j := 0; j < samplesCount; j++ { |
| 3220 | // Distribute samples evenly across the time range |
| 3221 | offset := (uint64(j) * timeRange) / uint64(samplesCount) |
| 3222 | ts := time.Unix(0, int64(start+offset)).UnixMilli() |
| 3223 | samples[j] = tempopb.Sample{ |
| 3224 | TimestampMs: ts, |
| 3225 | Value: float64(j % 100), // Simple pattern for test data |
| 3226 | } |
| 3227 | } |
| 3228 | |
| 3229 | // Create exemplars |
| 3230 | exemplars := make([]tempopb.Exemplar, exemplarCount) |
| 3231 | for j := 0; j < exemplarCount; j++ { |
| 3232 | // Distribute exemplars evenly across the time range |
| 3233 | offset := (uint64(j) * timeRange) / uint64(exemplarCount) |
| 3234 | ts := time.Unix(0, int64(start+offset)).UnixMilli() |
| 3235 | exemplarLabels := []commonv1proto.KeyValue{ |
| 3236 | { |
| 3237 | Key: "trace_id", |
| 3238 | Value: &commonv1proto.AnyValue{ |
| 3239 | Value: &commonv1proto.AnyValue_StringValue{ |
| 3240 | StringValue: fmt.Sprintf("trace-%d", i*1000+j), |
| 3241 | }, |
| 3242 | }, |
| 3243 | }, |
| 3244 | { |
| 3245 | Key: "span_id", |
| 3246 | Value: &commonv1proto.AnyValue{ |
| 3247 | Value: &commonv1proto.AnyValue_StringValue{ |
| 3248 | StringValue: fmt.Sprintf("span-%d", j), |
| 3249 | }, |
no outgoing calls
no test coverage detected