feat: Add eBPF prctl monitor to detect late OTEL_CTX publication#65
Open
nsavoire wants to merge 1 commit into
Open
feat: Add eBPF prctl monitor to detect late OTEL_CTX publication#65nsavoire wants to merge 1 commit into
nsavoire wants to merge 1 commit into
Conversation
0d29a15 to
2184a6a
Compare
b2ac7c2 to
bfc39c1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2ac7c27f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c6128c7 to
8069d0c
Compare
8069d0c to
510d211
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an eBPF tracepoint on
sys_enter_prctlthat detects when a tracked process names an anonymous VMA OTEL_CTX viaprctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, "OTEL_CTX"), and triggers a PID resynchronization so the newly-published process context mapping is observed without waiting for the nextSynchronizeProcess.Without this hook, a process that publishes its OTEL_CTX mapping after the profiler has already synchronized might never have its resource attributes attached to profiles since
SynchronizeProcessonly re-runs when the unwinder hits an unknown executable mapping, and OTEL_CTX is neither executable nor reachable from a stack.Implementation notes
op == PR_SET_VMAandarg2 == PR_SET_VMA_ANON_NAMEand checks that passed string is "OTEL_CTX".bpf.num_prctl_set_vma_otel_ctxcounts how often the resync hook fires./proc/PID/mapsto locate the OTEL_CTX mapping. Since the tracepoint already has the mapping's address and length, a future optimization could introduce a dedicated event type that hands those values directly toreadProcessContext, skipping the full/proc/PID/mapsre-parse.Note: this PR includes the commits from open-telemetry#1343 as a base, only the last commit (Add prctl monitor) is new to this PR. Reviewers should focus on that commit, the rest will go away once open-telemetry#1343 lands.