AddRandomDedicatedAttributes adds a random subset of the package test dedicated columns (dedicatedColumnsResource, dedicatedColumnsSpan, dedicatedColumnsEvent) at resource, span, and event levels (each existing span event). String columns with the blob option receive DedicatedBlobTestSize random let
(trace *tempopb.Trace)
| 382 | // Parquet round-trips may reorder attributes; use model/trace.SortTraceAndAttributes before |
| 383 | // proto.Equal when comparing decoded traces. |
| 384 | func AddRandomDedicatedAttributes(trace *tempopb.Trace) *tempopb.Trace { |
| 385 | for _, batch := range trace.ResourceSpans { |
| 386 | if batch.Resource != nil { |
| 387 | for i, col := range dedicatedColumnsResource { |
| 388 | if rand.Intn(2) != 0 { // nolint:gosec // G404: 50% each column |
| 389 | continue |
| 390 | } |
| 391 | batch.Resource.Attributes = append(batch.Resource.Attributes, &v1_common.KeyValue{ |
| 392 | Key: col.Name, |
| 393 | Value: anyValueForDedicatedColumn(col, i), |
| 394 | }) |
| 395 | } |
| 396 | } |
| 397 | for _, ss := range batch.ScopeSpans { |
| 398 | for _, span := range ss.Spans { |
| 399 | if span == nil { |
| 400 | continue |
| 401 | } |
| 402 | for i, col := range dedicatedColumnsSpan { |
| 403 | if rand.Intn(2) != 0 { // nolint:gosec // G404 |
| 404 | continue |
| 405 | } |
| 406 | span.Attributes = append(span.Attributes, &v1_common.KeyValue{ |
| 407 | Key: col.Name, |
| 408 | Value: anyValueForDedicatedColumn(col, i), |
| 409 | }) |
| 410 | } |
| 411 | |
| 412 | for _, e := range span.Events { |
| 413 | if e == nil { |
| 414 | continue |
| 415 | } |
| 416 | for i, col := range dedicatedColumnsEvent { |
| 417 | if rand.Intn(2) != 0 { // nolint:gosec // G404 |
| 418 | continue |
| 419 | } |
| 420 | e.Attributes = append(e.Attributes, &v1_common.KeyValue{ |
| 421 | Key: col.Name, |
| 422 | Value: anyValueForDedicatedColumn(col, i), |
| 423 | }) |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | return trace |
| 431 | } |
| 432 | |
| 433 | func MakeReqWithMultipleTraceWithSpanCount(spanCounts []int, traceIDs [][]byte) *tempopb.Trace { |
| 434 | if len(spanCounts) != len(traceIDs) { |