Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(evpn-bridge): make tracer optional #380

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we need to check a tracer all the time here and there...
Is it possible to use NoopTracerProvider here, so we use that noop object and not checking for nil all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a very good point. Let me take a look

}
return netlinkWrapper
}

// build time check that struct implements interface
Expand Down
Loading