(spans int, traceID []byte, timeRange *batchTimeRange, resAttributes []*v1_common.KeyValue)
| 177 | } |
| 178 | |
| 179 | func makeBatchWithTimeRange(spans int, traceID []byte, timeRange *batchTimeRange, resAttributes []*v1_common.KeyValue) *v1_trace.ResourceSpans { |
| 180 | traceID = ValidTraceID(traceID) |
| 181 | |
| 182 | batch := &v1_trace.ResourceSpans{ |
| 183 | Resource: &v1_resource.Resource{ |
| 184 | Attributes: []*v1_common.KeyValue{ |
| 185 | { |
| 186 | Key: "random.res.attr", |
| 187 | Value: &v1_common.AnyValue{ |
| 188 | Value: &v1_common.AnyValue_StringValue{ |
| 189 | StringValue: RandomString(), |
| 190 | }, |
| 191 | }, |
| 192 | }, |
| 193 | { |
| 194 | Key: "service.name", |
| 195 | Value: &v1_common.AnyValue{ |
| 196 | Value: &v1_common.AnyValue_StringValue{ |
| 197 | StringValue: "test-service", |
| 198 | }, |
| 199 | }, |
| 200 | }, |
| 201 | }, |
| 202 | }, |
| 203 | } |
| 204 | |
| 205 | if resAttributes != nil { |
| 206 | batch.Resource.Attributes = append(batch.Resource.Attributes, resAttributes...) |
| 207 | } |
| 208 | |
| 209 | var ( |
| 210 | ss *v1_trace.ScopeSpans |
| 211 | ssCount int |
| 212 | ) |
| 213 | |
| 214 | for range spans { |
| 215 | // occasionally make a new ss |
| 216 | if ss == nil || rand.Int()%3 == 0 { // nolint:gosec // G404: Use of weak random number generator |
| 217 | ssCount++ |
| 218 | ss = &v1_trace.ScopeSpans{ |
| 219 | Scope: &v1_common.InstrumentationScope{ |
| 220 | Name: "super library", |
| 221 | Version: fmt.Sprintf("1.0.%d", ssCount), |
| 222 | }, |
| 223 | } |
| 224 | |
| 225 | batch.ScopeSpans = append(batch.ScopeSpans, ss) |
| 226 | } |
| 227 | |
| 228 | if timeRange == nil { |
| 229 | ss.Spans = append(ss.Spans, MakeSpan(traceID)) |
| 230 | } else { |
| 231 | ss.Spans = append(ss.Spans, MakeSpanWithTimeWindow(traceID, timeRange.start, timeRange.end)) |
| 232 | } |
| 233 | } |
| 234 | return batch |
| 235 | } |
| 236 |
no test coverage detected