mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-13 11:30:31 +02:00
Use slices.SortFunc in OTLP trace exporter instead of sort.Slice (#4989)
Co-authored-by: Sam Xie <sam@samxie.me>
This commit is contained in:
parent
32f3933456
commit
0510d11b8d
@ -7,7 +7,8 @@
|
||||
package otlptracetest // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlptracetest"
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"cmp"
|
||||
"slices"
|
||||
|
||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
@ -88,8 +89,8 @@ func resourceString(res *resourcepb.Resource) string {
|
||||
}
|
||||
|
||||
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||
sort.Slice(attrs[:], func(i, j int) bool {
|
||||
return attrs[i].Key < attrs[j].Key
|
||||
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||
return cmp.Compare(a.Key, b.Key)
|
||||
})
|
||||
return attrs
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
package otlptracetest // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlptracetest"
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"cmp"
|
||||
"slices"
|
||||
|
||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
@ -88,8 +89,8 @@ func resourceString(res *resourcepb.Resource) string {
|
||||
}
|
||||
|
||||
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||
sort.Slice(attrs[:], func(i, j int) bool {
|
||||
return attrs[i].Key < attrs[j].Key
|
||||
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||
return cmp.Compare(a.Key, b.Key)
|
||||
})
|
||||
return attrs
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
package otlptracetest
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"cmp"
|
||||
"slices"
|
||||
|
||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
@ -88,8 +89,8 @@ func resourceString(res *resourcepb.Resource) string {
|
||||
}
|
||||
|
||||
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||
sort.Slice(attrs[:], func(i, j int) bool {
|
||||
return attrs[i].Key < attrs[j].Key
|
||||
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||
return cmp.Compare(a.Key, b.Key)
|
||||
})
|
||||
return attrs
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user