-
Notifications
You must be signed in to change notification settings - Fork 11
Initial implementation of OTel process context support #266
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
Conversation
ivoanjo
left a comment
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.
Nice! Looks like it was very straightforward to wire this in, which was the point :)
Left a few notes.
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.
Ah, I can see why having a no-op fallback may be useful for implementers. I'll borrow steal build on this idea and add it on the reference implementation so we don't need to maintain it separately
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.
Update: https://github.com/DataDog/fullhost-code-hotspots-wip/pull/2 now has a no-op implementation
ddprof-lib/src/main/java/com/datadoghq/profiler/OTelContext.java
Outdated
Show resolved
Hide resolved
ddprof-lib/src/main/java/com/datadoghq/profiler/OTelContext.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Ivo Anjo <ivo@ivoanjo.me>
- Add comprehensive gradle patching for otel_process_ctx.c to .cpp conversion - Add Linux preprocessor guards and C++ explicit casts for compilation - Fix gradle task dependencies and caching for proper file handling - Implement proper publish/update API usage in JNI setProcessCtx0 - Add native read functionality through JNI wrapper - Update ProcessContextTest for test resilience and native read testing - Resolve all compilation failures in gtest tasks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ivoanjo
left a comment
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.
👍 LGTM left a few small notes, but overall looks very reasonable!
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-test/src/test/java/com/datadoghq/profiler/context/ProcessContextTest.java
Outdated
Show resolved
Hide resolved
ddprof-lib/src/main/java/com/datadoghq/profiler/OTelContext.java
Outdated
Show resolved
Hide resolved
ddprof-lib/src/main/java/com/datadoghq/profiler/OTelContext.java
Outdated
Show resolved
Hide resolved
|
I've opened #267 to bring the latest version of the reference library on top of this PR/branch :) |
…ference library (#267)
|
@zhengyu123 I addressed the locking. If you could re-review and potentially approve ... |
|
Exciting to see this! 👏 |
|
@r1viollet Can you 👍 this? |
| // (due to the MADV_DONTFORK) and we don't need to do anything to it. | ||
| if (state.mapping != NULL && state.mapping != MAP_FAILED && getpid() == state.publisher_pid) { | ||
| long mapping_size = size_for_mapping(); | ||
| if (mapping_size == -1 || munmap(published_state.mapping, mapping_size) == -1) return false; |
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.
confusion between state.mapping and published_state.mapping
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.
Really nice spot! I'll open a PR to fix this.
| data_out->telemetry_sdk_name = value; | ||
| } else { | ||
| // Unknown key, put it into resources | ||
| char *key = (char *) calloc(key_len + 1, 1); |
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.
Could we avoid the manual allocs ? if we have to handle frees on error we will make mistakes
example not freeing other resources (data_out->resources )
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.
Note that the resources are being cleared in the caller:
if (!otel_process_ctx_decode_payload(mapping->otel_process_payload, &data)) {
otel_process_ctx_read_data_drop(data);For avoiding manual allocs, any suggestions? Were you thinking something closer to -- allocate a big block of and then just memcpy into it?
(Also the reading support is mostly only for debugging/tests and can even be disabled individually, as it's not particularly interesting in actual production apps)
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.
Disclaimer: when I initially wrote this I forgot that we had to be compatible with C 😄
In C++ the types would have defined the ownership.
In C, we can try to be more symmetrical on alloc / free code paths: having clear init / free functions to look for.
I'm not sure we need to polish this right now.
|
More generally I think we need to consider invalid inputs, size limits, null values (as these can come from users). Java might be handling some of this. This is not a blocker for prototype. |
I believe all of these are checked?
We definitely want to make this as production-quality as possible (especially the writer, but the reader as a bonus) so all feedback for that is welcome |
What does this PR do?:
It adds the support for publishing process context in OTel friendly way.
Additional Notes:
See https://github.com/DataDog/fullhost-code-hotspots-wip/pull/2
How to test the change?:
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!