MCPcopy
hub / github.com/grafana/tempo / AddDedicatedAttributes

Function AddDedicatedAttributes

pkg/util/test/req.go:309–375  ·  view source on GitHub ↗

AddDedicatedAttributes adds resource and span attributes to a trace that are stored in dedicated columns when a backend.BlockMeta is created with the column assignments from MakeDedicatedColumns.

(trace *tempopb.Trace)

Source from the content-addressed store, hash-verified

307// AddDedicatedAttributes adds resource and span attributes to a trace that are stored in dedicated
308// columns when a backend.BlockMeta is created with the column assignments from MakeDedicatedColumns.
309func AddDedicatedAttributes(trace *tempopb.Trace) *tempopb.Trace {
310 makeVal := func(c backend.DedicatedColumn, i int) *v1_common.AnyValue {
311 if c.Type == backend.DedicatedColumnTypeInt {
312 return &v1_common.AnyValue{
313 Value: &v1_common.AnyValue_IntValue{
314 IntValue: int64(i + 1),
315 },
316 }
317 }
318 if slices.Contains(c.Options, backend.DedicatedColumnOptionBlob) {
319 return &v1_common.AnyValue{
320 Value: &v1_common.AnyValue_StringValue{
321 StringValue: DedicatedBlobTestString(),
322 },
323 }
324 }
325 return &v1_common.AnyValue{
326 Value: &v1_common.AnyValue_StringValue{
327 StringValue: fmt.Sprintf("dedicated-%s-attr-value-%d", c.Scope, i+1),
328 },
329 }
330 }
331
332 spanAttrs := make([]*v1_common.KeyValue, 0, len(dedicatedColumnsSpan))
333 for i, c := range dedicatedColumnsSpan {
334 spanAttrs = append(spanAttrs, &v1_common.KeyValue{
335 Key: c.Name,
336 Value: makeVal(c, i),
337 })
338 }
339 resourceAttrs := make([]*v1_common.KeyValue, 0, len(dedicatedColumnsResource))
340 for i, c := range dedicatedColumnsResource {
341 resourceAttrs = append(resourceAttrs, &v1_common.KeyValue{
342 Key: c.Name,
343 Value: makeVal(c, i),
344 })
345 }
346 eventAttrs := make([]*v1_common.KeyValue, 0, len(dedicatedColumnsEvent))
347 for i, c := range dedicatedColumnsEvent {
348 eventAttrs = append(eventAttrs, &v1_common.KeyValue{
349 Key: c.Name,
350 Value: makeVal(c, i),
351 })
352 }
353
354 for _, batch := range trace.ResourceSpans {
355 attr := make([]*v1_common.KeyValue, 0, len(resourceAttrs)+len(batch.Resource.Attributes))
356 attr = append(attr, resourceAttrs...)
357 batch.Resource.Attributes = append(attr, batch.Resource.Attributes...)
358
359 for _, ss := range batch.ScopeSpans {
360 for _, span := range ss.Spans {
361 attr = make([]*v1_common.KeyValue, 0, len(spanAttrs)+len(span.Attributes))
362 attr = append(attr, spanAttrs...)
363 span.Attributes = append(attr, span.Attributes...)
364
365 for _, e := range span.Events {
366 attr = make([]*v1_common.KeyValue, 0, len(eventAttrs)+len(e.Attributes))

Callers 14

TestProtoParquetRandoFunction · 0.92
BenchmarkProtoToParquetFunction · 0.92
BenchmarkDeconstructFunction · 0.92
BenchmarkTraceToParquetFunction · 0.92
createTestBlockFunction · 0.92
TestProtoParquetRandoFunction · 0.92
BenchmarkProtoToParquetFunction · 0.92
BenchmarkDeconstructFunction · 0.92
BenchmarkTraceToParquetFunction · 0.92
createTestBlockFunction · 0.92
TestProtoParquetRandoFunction · 0.92
BenchmarkProtoToParquetFunction · 0.92

Calls 1

DedicatedBlobTestStringFunction · 0.85

Tested by 14

TestProtoParquetRandoFunction · 0.74
BenchmarkProtoToParquetFunction · 0.74
BenchmarkDeconstructFunction · 0.74
BenchmarkTraceToParquetFunction · 0.74
createTestBlockFunction · 0.74
TestProtoParquetRandoFunction · 0.74
BenchmarkProtoToParquetFunction · 0.74
BenchmarkDeconstructFunction · 0.74
BenchmarkTraceToParquetFunction · 0.74
createTestBlockFunction · 0.74
TestProtoParquetRandoFunction · 0.74
BenchmarkProtoToParquetFunction · 0.74