pkg/tracing: rename func that shadowed builtin, rm makeSpanName
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e49d3fd1bc
commit
e2e09b384a
@ -19,20 +19,11 @@ package tracing
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func keyValue(k string, v any) attribute.KeyValue {
|
||||||
spanDelimiter = "."
|
|
||||||
)
|
|
||||||
|
|
||||||
func makeSpanName(names ...string) string {
|
|
||||||
return strings.Join(names, spanDelimiter)
|
|
||||||
}
|
|
||||||
|
|
||||||
func any(k string, v interface{}) attribute.KeyValue {
|
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return attribute.String(k, "<nil>")
|
return attribute.String(k, "<nil>")
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (h *LogrusHook) Fire(entry *logrus.Entry) error {
|
|||||||
func logrusDataToAttrs(data logrus.Fields) []attribute.KeyValue {
|
func logrusDataToAttrs(data logrus.Fields) []attribute.KeyValue {
|
||||||
attrs := make([]attribute.KeyValue, 0, len(data))
|
attrs := make([]attribute.KeyValue, 0, len(data))
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
attrs = append(attrs, any(k, v))
|
attrs = append(attrs, keyValue(k, v))
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package tracing
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
@ -99,14 +100,16 @@ func (s *Span) SetAttributes(kv ...attribute.KeyValue) {
|
|||||||
s.otelSpan.SetAttributes(kv...)
|
s.otelSpan.SetAttributes(kv...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const spanDelimiter = "."
|
||||||
|
|
||||||
// Name sets the span name by joining a list of strings in dot separated format.
|
// Name sets the span name by joining a list of strings in dot separated format.
|
||||||
func Name(names ...string) string {
|
func Name(names ...string) string {
|
||||||
return makeSpanName(names...)
|
return strings.Join(names, spanDelimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute takes a key value pair and returns attribute.KeyValue type.
|
// Attribute takes a key value pair and returns attribute.KeyValue type.
|
||||||
func Attribute(k string, v interface{}) attribute.KeyValue {
|
func Attribute(k string, v any) attribute.KeyValue {
|
||||||
return any(k, v)
|
return keyValue(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry
|
// HTTPStatusCodeAttributes generates attributes of the HTTP namespace as specified by the OpenTelemetry
|
||||||
|
Loading…
Reference in New Issue
Block a user