File tree 2 files changed +9
-5
lines changed
instrumentation/google.golang.org/grpc/otelgrpc/internal
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
12
12
13
13
- Add the new ` go.opentelemetry.io/contrib/instrgen ` package to provide auto-generated source code instrumentation. (#3068 , #3108 )
14
14
15
+ ### Changed
16
+
17
+ - Use ` strings.Cut() ` instead of ` string.SplitN() ` for better readability and memory use. (#3822 )
18
+
15
19
## [ 1.17.0-rc.1/0.42.0-rc.1/0.11.0-rc.1] - 2023-05-17
16
20
17
21
### Changed
Original file line number Diff line number Diff line change @@ -26,17 +26,17 @@ import (
26
26
// on a gRPC's FullMethod.
27
27
func ParseFullMethod (fullMethod string ) (string , []attribute.KeyValue ) {
28
28
name := strings .TrimLeft (fullMethod , "/" )
29
- parts := strings .SplitN (name , "/" , 2 )
30
- if len ( parts ) != 2 {
29
+ service , method , found := strings .Cut (name , "/" )
30
+ if ! found {
31
31
// Invalid format, does not follow `/package.service/method`.
32
- return name , []attribute. KeyValue ( nil )
32
+ return name , nil
33
33
}
34
34
35
35
var attrs []attribute.KeyValue
36
- if service := parts [ 0 ]; service != "" {
36
+ if service != "" {
37
37
attrs = append (attrs , semconv .RPCService (service ))
38
38
}
39
- if method := parts [ 1 ]; method != "" {
39
+ if method != "" {
40
40
attrs = append (attrs , semconv .RPCMethod (method ))
41
41
}
42
42
return name , attrs
You can’t perform that action at this time.
0 commit comments