File tree Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -19,20 +19,11 @@ package tracing
19
19
import (
20
20
"encoding/json"
21
21
"fmt"
22
- "strings"
23
22
24
23
"go.opentelemetry.io/otel/attribute"
25
24
)
26
25
27
- const (
28
- spanDelimiter = "."
29
- )
30
-
31
- func makeSpanName (names ... string ) string {
32
- return strings .Join (names , spanDelimiter )
33
- }
34
-
35
- func any (k string , v interface {}) attribute.KeyValue {
26
+ func keyValue (k string , v any ) attribute.KeyValue {
36
27
if v == nil {
37
28
return attribute .String (k , "<nil>" )
38
29
}
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func (h *LogrusHook) Fire(entry *logrus.Entry) error {
60
60
func logrusDataToAttrs (data logrus.Fields ) []attribute.KeyValue {
61
61
attrs := make ([]attribute.KeyValue , 0 , len (data ))
62
62
for k , v := range data {
63
- attrs = append (attrs , any (k , v ))
63
+ attrs = append (attrs , keyValue (k , v ))
64
64
}
65
65
return attrs
66
66
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package tracing
19
19
import (
20
20
"context"
21
21
"net/http"
22
+ "strings"
22
23
23
24
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
24
25
"go.opentelemetry.io/otel"
@@ -99,14 +100,16 @@ func (s *Span) SetAttributes(kv ...attribute.KeyValue) {
99
100
s .otelSpan .SetAttributes (kv ... )
100
101
}
101
102
103
+ const spanDelimiter = "."
104
+
102
105
// Name sets the span name by joining a list of strings in dot separated format.
103
106
func Name (names ... string ) string {
104
- return makeSpanName (names ... )
107
+ return strings . Join (names , spanDelimiter )
105
108
}
106
109
107
110
// Attribute takes a key value pair and returns attribute.KeyValue type.
108
- func Attribute (k string , v interface {} ) attribute.KeyValue {
109
- return any (k , v )
111
+ func Attribute (k string , v any ) attribute.KeyValue {
112
+ return keyValue (k , v )
110
113
}
111
114
112
115
// HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry
You can’t perform that action at this time.
0 commit comments