From 44e128c1758993b81dc16a60fb6061ec984d89f0 Mon Sep 17 00:00:00 2001 From: Dmitry Anoshin Date: Fri, 27 Sep 2024 09:43:22 -0700 Subject: [PATCH] Update otlptext --- exporter/internal/otlptext/databuffer.go | 15 +++++++++++++++ exporter/internal/otlptext/resource.go | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/exporter/internal/otlptext/databuffer.go b/exporter/internal/otlptext/databuffer.go index cf7fd630e78..36b1f1fddd4 100644 --- a/exporter/internal/otlptext/databuffer.go +++ b/exporter/internal/otlptext/databuffer.go @@ -280,6 +280,21 @@ func (b *dataBuffer) logExemplars(description string, se pmetric.ExemplarSlice) } } +func (b *dataBuffer) logResourceEntities(rers pcommon.ResourceEntityRefSlice) { + if rers.Len() == 0 { + return + } + + b.logEntry("Entities:") + for i := 0; i < rers.Len(); i++ { + rer := rers.At(i) + b.logEntry("Entity Ref #%d", i) + b.logEntry(" -> Entity Type: %s", rer.Type()) + b.logEntry(" -> Identifying Attributes: %s", strings.Join(rer.IdAttrKeys().AsRaw(), ", ")) + b.logEntry(" -> Descriptive Attributes: %s", strings.Join(rer.DescrAttrKeys().AsRaw(), ", ")) + } +} + func valueToString(v pcommon.Value) string { return fmt.Sprintf("%s(%s)", v.Type().String(), v.AsString()) } diff --git a/exporter/internal/otlptext/resource.go b/exporter/internal/otlptext/resource.go index f9b5652974d..ad02ccfcefd 100644 --- a/exporter/internal/otlptext/resource.go +++ b/exporter/internal/otlptext/resource.go @@ -9,6 +9,5 @@ import ( func marshalResource(res pcommon.Resource, buf *dataBuffer) { buf.logAttributes("Resource attributes", res.Attributes()) - buf.logEntry("Entity Type: %s", res.EntityType()) - buf.logAttributes("Entity Id", res.EntityId()) + buf.logResourceEntities(res.Entities()) }