-
Notifications
You must be signed in to change notification settings - Fork 93
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
Enable auto/sdk in otel global #1405
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
bc3fd1e
to
2cc75b0
Compare
0fa0bd8
to
555a184
Compare
This comment was marked as outdated.
This comment was marked as outdated.
555a184
to
dab479a
Compare
internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/bpf/probe.bpf.c
Show resolved
Hide resolved
d5356ef
to
89c0867
Compare
b25ff44
to
30e7015
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very cool to see it all come together,
Left some comments but it looks great.
internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/probe.go
Outdated
Show resolved
Hide resolved
@@ -365,50 +371,76 @@ type Uprobe struct { | |||
// function specified by Sym. If ReturnProbe is empty, no eBPF program will be attached to the return of the function. | |||
ReturnProbe string | |||
DependsOn []string | |||
|
|||
closers atomic.Pointer[[]io.Closer] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not []io.Closer
?
What are the concurrent scenarios we are trying to protect against?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Uprobe.Close
is called by the Manager
which can shutdown asynchronously. For example, this can occur when the context passed to the new Instrumentation
is canceled asynchronously1. This is to prevent that data-race.
Footnotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Do you think we can use sync.Once
instead? I think it might be more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sync.Once
would mean we need two fields here. One for the sync.Once
and the other to hold the closer slice. I think having a single field is cleaner. It does not require a user to understand the implicit coupling between two fields and avoids the error case when they are not correctly handled.
Alternatively, we could use a sync.OnceFunc
as a single field. However, this would leave a data-race when trying to replace the "swap" functionality. We would want to check if the "close" field is non-nil before assigning to it in load
. This would need a semaphore to ensure no data-race, and again mean we require two fields.
It may also be tempting to not implement the "swap" functionality. That way we would just assign blindly on load and hope for the best on close (meaning there would be a data-race there). However, data-race asside, that would mean we no longer support instrumentation shutdown and then restarting, or probe unloading and reloading.
We could also use atomic.Value
here. That was explored, but decided against due to the lack of type safety and the inability to set a value of nil
(representing a state of stopped) without a panic.
internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/probe.go
Outdated
Show resolved
Hide resolved
internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/probe.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add package constraints on the auto sdk probes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to always add uprobes for auto/sdk
. If that package is loaded, it may be because the user has done so explicitly and we don't want to not instrument it because of the version of otel
. It also doesn't add runtime overhead if it is not used given the uprobe break-point is never triggered.
internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/probe.go
Outdated
Show resolved
Hide resolved
@@ -365,50 +371,76 @@ type Uprobe struct { | |||
// function specified by Sym. If ReturnProbe is empty, no eBPF program will be attached to the return of the function. | |||
ReturnProbe string | |||
DependsOn []string | |||
|
|||
closers atomic.Pointer[[]io.Closer] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Do you think we can use sync.Once
instead? I think it might be more readable
Set the auto/sdk flag in the global API to true when newSpan is called.
Verify the auto/sdk probe is being used.
955785e
to
4b55aa7
Compare
The span embedded within a context will be from `auto/sdk`. This means that open-telemetry#974 is resolved by this change.
Resolve #1399
Resolve #1400
Resolve #974
This includes a
probe.Uprobe
refactor. Instead of passing backlinks
when the uprobe loads, the uprobe itself now hold these values. When itsClose
method is called it will, itself, call each of these close methods.This redesign is used so that the
newSpan
uprobe can be closed prior to the others (which are closed by theManager
).