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

Track un-active instrumentation for better reporting #2016

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

RonFed
Copy link
Collaborator

@RonFed RonFed commented Dec 16, 2024

This PR changes when the instrumentation manager tracks an instrumentation.
Once an instrumentation is initialized, we should start tracking it even if it fails to load.
The reason is, that we need to call the reporter once the process exits (so it can report/clean it) - however, if we only track the PID once the instrumentation is loaded we won't be able to invoke the reporter properly once a failed-to-load instrumentation needs to be cleaned.

Each PID we track is marked whether the instrumentation is active (loaded successfully) or not - by the inst field being nil or not.
For un-active PIDs we won't apply config updates.

In addition, in case we get an exec event on a non-active PID, we try to instrument it again. This is helpful in cases of chain-loading where the first executable is written in a language we can't instrument, while the second is valid for instrumentation.

@RonFed RonFed marked this pull request as draft December 16, 2024 15:48
@RonFed RonFed marked this pull request as ready for review December 16, 2024 16:53
@RonFed RonFed requested a review from blumamir December 16, 2024 17:00
// we need to track the instrumentation even if the load failed.
// consider a reporter which writes a persistent record for a failed/successful load
// we need to notify the reporter once that PID exists to clean up the resources
m.startTrackInstrumentation(e.PID, inst, pg, configGroup, loadErr == nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we had an error with the Load, it means that at this point the inst is not longer relevant. We will not need to call Close or apply config to it since it's not loaded. Thus, I recommend to consider using nil instead of inst in this case so that it doesn't get called accidentally and cause hard to find bug

// active is used to track if the instrumentation is loaded successfully or not.
// we want to track the instrumentation even if it failed to load, to be able to report the error
// and clean up the instrumentation resources and the reporter resources once the process exits.
active bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider:

Suggested change
active bool
loaded bool

to maintain a consistent terminology with existing terms.

@RonFed RonFed merged commit 716aac7 into odigos-io:main Dec 17, 2024
31 checks passed
@RonFed RonFed deleted the ebpf_manager_track_failed_loads branch December 17, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants