Skip to content

Commit

Permalink
fill empty event names + delete instrumentationname
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Dec 30, 2021
1 parent 711ab40 commit 5b777b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions pkg/networkservice/common/metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"go.opentelemetry.io/otel/metric/global"

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

type metricServer struct {
Expand All @@ -40,7 +39,7 @@ type metricServer struct {
func NewServer() networkservice.NetworkServiceServer {
return &metricServer{
recorderMap: make(map[string]metric.Int64Histogram),
meter: global.Meter(opentelemetry.InstrumentationName),
meter: global.Meter(""),
}
}

Expand Down
13 changes: 6 additions & 7 deletions pkg/tools/log/spanlogger/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
opentelemetry "go.opentelemetry.io/otel/trace"

opentelemetrynsm "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// Span - unified interface for opentracing/opentelemetry spans
Expand Down Expand Up @@ -81,12 +79,13 @@ func newOTSpan(ctx context.Context, operationName string, additionalFields map[s

// Opentelemetry span
type otelSpan struct {
span opentelemetry.Span
span opentelemetry.Span
operationName string
}

func (otelsp *otelSpan) Log(level, format string, v ...interface{}) {
otelsp.span.AddEvent(
"",
otelsp.operationName,
opentelemetry.WithAttributes([]attribute.KeyValue{
attribute.String("event", level),
attribute.String("message", fmt.Sprintf(format, v...)),
Expand All @@ -96,7 +95,7 @@ func (otelsp *otelSpan) Log(level, format string, v ...interface{}) {

func (otelsp *otelSpan) LogObject(k, v interface{}) {
otelsp.span.AddEvent(
"",
otelsp.operationName,
opentelemetry.WithAttributes([]attribute.KeyValue{
attribute.String(fmt.Sprintf("%v", k), fmt.Sprintf("%v", v)),
}...),
Expand Down Expand Up @@ -126,8 +125,8 @@ func newOTELSpan(ctx context.Context, operationName string, additionalFields map
add = append(add, attribute.String(k, fmt.Sprint(v)))
}

ctx, span := otel.Tracer(opentelemetrynsm.InstrumentationName).Start(ctx, operationName)
ctx, span := otel.Tracer("").Start(ctx, operationName)
span.SetAttributes(add...)

return ctx, &otelSpan{span: span}
return ctx, &otelSpan{span: span, operationName: operationName}
}
5 changes: 0 additions & 5 deletions pkg/tools/opentelemetry/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/log"
)

const (
// InstrumentationName - denotes the library that provides the instrumentation
InstrumentationName = "NSM"
)

type opentelemetry struct {
io.Closer

Expand Down

0 comments on commit 5b777b9

Please sign in to comment.