Skip to content

Commit

Permalink
fix(evpn-bridge): make tracer optional
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Markou <dimitrios.markou@ericsson.com>
  • Loading branch information
mardim91 committed May 14, 2024
1 parent d33fbef commit 3342b84
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 10 additions & 4 deletions pkg/utils/frr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
)

const (
Expand Down Expand Up @@ -64,13 +65,18 @@ type FrrWrapper struct {

// NewFrrWrapper creates initialized instance of FrrWrapper with default address
func NewFrrWrapper() *FrrWrapper {
return NewFrrWrapperWithArgs(defaultAddress)
return NewFrrWrapperWithArgs(defaultAddress, true)
}

// NewFrrWrapperWithArgs creates initialized instance of FrrWrapper
func NewFrrWrapperWithArgs(address string) *FrrWrapper {
// default tracer name is good for now
return &FrrWrapper{address: address, tracer: otel.Tracer("")}
func NewFrrWrapperWithArgs(address string, enableTracer bool) *FrrWrapper {
frrWrapper := &FrrWrapper{address: address}
frrWrapper.tracer = noop.NewTracerProvider().Tracer("")
if enableTracer {
// default tracer name is good for now
frrWrapper.tracer = otel.Tracer("")
}
return frrWrapper
}

// build time check that struct implements interface
Expand Down
14 changes: 13 additions & 1 deletion pkg/utils/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
)

// Netlink represents limited subset of functions from netlink package
Expand Down Expand Up @@ -73,7 +74,18 @@ type NetlinkWrapper struct {

// NewNetlinkWrapper creates initialized instance of NetlinkWrapper
func NewNetlinkWrapper() *NetlinkWrapper {
return &NetlinkWrapper{tracer: otel.Tracer("")}
return NewNetlinkWrapperWithArgs(true)
}

// NewNetlinkWrapperWithArgs creates initialized instance of NetlinkWrapper
// based on passing arguments
func NewNetlinkWrapperWithArgs(enableTracer bool) *NetlinkWrapper {
netlinkWrapper := &NetlinkWrapper{}
netlinkWrapper.tracer = noop.NewTracerProvider().Tracer("")
if enableTracer {
netlinkWrapper.tracer = otel.Tracer("")
}
return netlinkWrapper
}

// build time check that struct implements interface
Expand Down

0 comments on commit 3342b84

Please sign in to comment.