Skip to content

Commit

Permalink
Simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Jan 17, 2024
1 parent 5d37b81 commit 51bef51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 0 additions & 8 deletions exporter/elasticsearchexporter/internal/objmodel/objmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,6 @@ func (doc *Document) Serialize(w io.Writer, dedot bool) error {
return doc.iterJSON(v, dedot)
}

// MergeFrom merges the fields of anotherDoc into doc, overwriting any existing fields.
func (doc *Document) MergeFrom(anotherDoc Document) {
for _, field := range anotherDoc.fields {
doc.Add(field.key, field.value)
}
doc.Dedup()
}

func (doc *Document) iterJSON(v *json.Visitor, dedot bool) error {
if dedot {
return doc.iterJSONDedot(v)
Expand Down
6 changes: 4 additions & 2 deletions exporter/elasticsearchexporter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ func (m *encodeModel) encodeSpan(resource pcommon.Resource, span ptrace.Span, sc

func (m *encodeModel) encodeAttributes(document *objmodel.Document, attributes pcommon.Map) {
if m.omitAttributesPrefix {
rawDoc := objmodel.DocumentFromAttributes(attributes)
document.MergeFrom(rawDoc)
attributes.Range(func(k string, v pcommon.Value) bool {
document.AddAttribute(k, v)
return true
})
} else {
document.AddAttributes("Attributes", attributes)
}
Expand Down

0 comments on commit 51bef51

Please sign in to comment.