From 19d0c949d74d1b9b362df41f70da266916256f33 Mon Sep 17 00:00:00 2001 From: Felix Barnsteiner Date: Sat, 11 Jan 2025 08:58:58 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Carson Ip --- exporter/elasticsearchexporter/bufferpol.go | 2 +- exporter/elasticsearchexporter/model.go | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/exporter/elasticsearchexporter/bufferpol.go b/exporter/elasticsearchexporter/bufferpol.go index cdb8f16fa696..b3070885513c 100644 --- a/exporter/elasticsearchexporter/bufferpol.go +++ b/exporter/elasticsearchexporter/bufferpol.go @@ -36,5 +36,5 @@ func (p pooledBuffer) recycle() { func (p pooledBuffer) WriteTo(w io.Writer) (n int64, err error) { defer p.recycle() - return bytes.NewReader(p.Buffer.Bytes()).WriteTo(w) + return p.Buffer.WriteTo(w) } diff --git a/exporter/elasticsearchexporter/model.go b/exporter/elasticsearchexporter/model.go index 88bcf6e7bdf0..458f481f2689 100644 --- a/exporter/elasticsearchexporter/model.go +++ b/exporter/elasticsearchexporter/model.go @@ -124,10 +124,9 @@ func (m *encodeModel) encodeLog(resource pcommon.Resource, resourceSchemaURL str default: document = m.encodeLogDefaultMode(resource, record, scope) } - // For OTel mode, prefix conflicts are not a problem as otel-data has subobjects: false - document.Dedup(m.mode != MappingOTel) + document.Dedup(true) - return document.Serialize(buf, m.dedot, m.mode == MappingOTel) + return document.Serialize(buf, m.dedot, false) } func (m *encodeModel) encodeLogDefaultMode(resource pcommon.Resource, record plog.LogRecord, scope pcommon.InstrumentationScope) objmodel.Document { @@ -204,10 +203,9 @@ func (m *encodeModel) encodeLogECSMode(resource pcommon.Resource, record plog.Lo } func (m *encodeModel) encodeDocument(document objmodel.Document, buf *bytes.Buffer) error { - // For OTel mode, prefix conflicts are not a problem as otel-data has subobjects: false - document.Dedup(m.mode != MappingOTel) + document.Dedup(true) - err := document.Serialize(buf, m.dedot, m.mode == MappingOTel) + err := document.Serialize(buf, m.dedot, false) if err != nil { return err } @@ -494,9 +492,8 @@ func (m *encodeModel) encodeSpan(resource pcommon.Resource, resourceSchemaURL st default: document = m.encodeSpanDefaultMode(resource, span, scope) } - // For OTel mode, prefix conflicts are not a problem as otel-data has subobjects: false - document.Dedup(m.mode != MappingOTel) - err := document.Serialize(buf, m.dedot, m.mode == MappingOTel) + document.Dedup(true) + err := document.Serialize(buf, m.dedot, false) return err }