Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Carson Ip <[email protected]>
  • Loading branch information
felixbarny and carsonip authored Jan 11, 2025
1 parent 29e9daf commit 19d0c94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/bufferpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
15 changes: 6 additions & 9 deletions exporter/elasticsearchexporter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 19d0c94

Please sign in to comment.