Skip to content

Commit e2e09b3

Browse files
committed
pkg/tracing: rename func that shadowed builtin, rm makeSpanName
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent e49d3fd commit e2e09b3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

pkg/tracing/helpers.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,11 @@ package tracing
1919
import (
2020
"encoding/json"
2121
"fmt"
22-
"strings"
2322

2423
"go.opentelemetry.io/otel/attribute"
2524
)
2625

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 {
3627
if v == nil {
3728
return attribute.String(k, "<nil>")
3829
}

pkg/tracing/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (h *LogrusHook) Fire(entry *logrus.Entry) error {
6060
func logrusDataToAttrs(data logrus.Fields) []attribute.KeyValue {
6161
attrs := make([]attribute.KeyValue, 0, len(data))
6262
for k, v := range data {
63-
attrs = append(attrs, any(k, v))
63+
attrs = append(attrs, keyValue(k, v))
6464
}
6565
return attrs
6666
}

pkg/tracing/tracing.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package tracing
1919
import (
2020
"context"
2121
"net/http"
22+
"strings"
2223

2324
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
2425
"go.opentelemetry.io/otel"
@@ -99,14 +100,16 @@ func (s *Span) SetAttributes(kv ...attribute.KeyValue) {
99100
s.otelSpan.SetAttributes(kv...)
100101
}
101102

103+
const spanDelimiter = "."
104+
102105
// Name sets the span name by joining a list of strings in dot separated format.
103106
func Name(names ...string) string {
104-
return makeSpanName(names...)
107+
return strings.Join(names, spanDelimiter)
105108
}
106109

107110
// 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)
110113
}
111114

112115
// HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry

0 commit comments

Comments
 (0)