Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/elasticsearch] Merge *.geo.location.{lat,lon} to *.geo.location in OTel mode #36594

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions exporter/elasticsearchexporter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,3 +998,29 @@ func sliceHash(h hash.Hash, s pcommon.Slice) {
valueHash(h, s.At(i))
}
}

// convertGeolocationToGeopoint mutates attributes map to merge `geo.location.lat` and `geo.location.lon` to `geo.location`.
func convertGeolocationToGeopoint(attributes pcommon.Map) {
const (
lonKey = "geo.location.lon"
latKey = "geo.location.lat"
carsonip marked this conversation as resolved.
Show resolved Hide resolved
mergedKey = "geo.location"
)
var lon, lat pcommon.Value
if v, ok := attributes.Get(lonKey); ok {
lon = v
}
if v, ok := attributes.Get(latKey); ok {
lat = v
}
if lon.Type() == pcommon.ValueTypeDouble && lat.Type() == pcommon.ValueTypeDouble {
attributes.PutStr(mergedKey, fmt.Sprintf("POINT(%f %f)", lon.Double(), lat.Double()))
attributes.RemoveIf(func(key string, val pcommon.Value) bool {
switch key {
case lonKey, latKey:
return true
}
return false
})
}
}
Loading