mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-23 11:58:56 +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"
|
package otlptracetest // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlptracetest"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"cmp"
|
||||||
|
"slices"
|
||||||
|
|
||||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||||
commonpb "go.opentelemetry.io/proto/otlp/common/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 {
|
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||||
sort.Slice(attrs[:], func(i, j int) bool {
|
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||||
return attrs[i].Key < attrs[j].Key
|
return cmp.Compare(a.Key, b.Key)
|
||||||
})
|
})
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
package otlptracetest // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlptracetest"
|
package otlptracetest // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlptracetest"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"cmp"
|
||||||
|
"slices"
|
||||||
|
|
||||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||||
commonpb "go.opentelemetry.io/proto/otlp/common/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 {
|
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||||
sort.Slice(attrs[:], func(i, j int) bool {
|
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||||
return attrs[i].Key < attrs[j].Key
|
return cmp.Compare(a.Key, b.Key)
|
||||||
})
|
})
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
package otlptracetest
|
package otlptracetest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"cmp"
|
||||||
|
"slices"
|
||||||
|
|
||||||
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
collectortracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||||
commonpb "go.opentelemetry.io/proto/otlp/common/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 {
|
func sortedAttributes(attrs []*commonpb.KeyValue) []*commonpb.KeyValue {
|
||||||
sort.Slice(attrs[:], func(i, j int) bool {
|
slices.SortFunc(attrs, func(a, b *commonpb.KeyValue) int {
|
||||||
return attrs[i].Key < attrs[j].Key
|
return cmp.Compare(a.Key, b.Key)
|
||||||
})
|
})
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user