Skip to content

Integrate dd-win-prof profiling feature into dd-sdk-cpp#185

Open
r1viollet wants to merge 9 commits into
mainfrom
r1viollet/profiling-integration
Open

Integrate dd-win-prof profiling feature into dd-sdk-cpp#185
r1viollet wants to merge 9 commits into
mainfrom
r1viollet/profiling-integration

Conversation

@r1viollet

@r1viollet r1viollet commented Mar 16, 2026

Copy link
Copy Markdown

Description

  • CMake: DD_ENABLE_PROFILER option, FetchContent for dd-win-prof
  • Public API: Profiling::Register() following Rum/Logging patterns
  • RUM context: RumContextSnapshot + callback wiring to dd-win-prof
  • Stub UploadThread_PrepareReport (dd-win-prof uploads independently)

Inspired from @aforsythe 's branch & co-authored using claude-4.6

Testing

e2e tests are ongoing
leaving as draft until I can add a test for the profiling integration

Follow up

  • Config needs to be unified
  • Profiling needs to work with tokens
  • e2e testing

Related PR

dd-win-prof PR

  - CMake: DD_ENABLE_PROFILER option, FetchContent for dd-win-prof
  - Public API: Profiling::Register() following Rum/Logging patterns
  - RUM context: RumContextSnapshot + callback wiring to dd-win-prof
  - Stub UploadThread_PrepareReport (dd-win-prof uploads independently)

Inspired from @aforsythe 's branch & co-authored using claude-4.6
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 16, 2026

Copy link
Copy Markdown

✅ Code Quality    ✅ Code Vulnerabilities    ✅ Library Vulnerabilities    ✅ Secrets

🎉 All green!

🛠️ No new code quality issues
🛡️ No new code vulnerabilities
📚 No new vulnerable libraries detected
🔑 No new secrets detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 23f5263 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Automatically wire profiling callback if RUM & profiling are active

co-authored using claude-4.6
@r1viollet r1viollet force-pushed the r1viollet/profiling-integration branch from 9c24469 to a1eea38 Compare March 17, 2026 10:34
Comment thread cmake/profiler.cmake Outdated
FetchContent_Declare(
dd-win-prof
GIT_REPOSITORY https://github.com/DataDog/dd-win-prof.git
GIT_TAG 74b9c6f

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this could be a param from CI

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

we can add this in later versions

@r1viollet r1viollet force-pushed the r1viollet/profiling-integration branch from a1eea38 to 18a7494 Compare March 17, 2026 10:42
Comment thread src/datadog/impl/features/profiling/profiling.cpp Outdated

// Wire RUM context changes → profiling: capture a weak_ptr so the callback
// doesn't extend the profiling feature's lifetime
std::weak_ptr<Profiling> weak_profiling = profiling_impl;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Do we feel this is OK ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@awforsythe I would need your advice on these parts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While the direct coupling of these two features isn't the cleanest approach, I think it's fine for now - it's an internal detail that can be changed without much disruption (AFAIK), and this code is only exercised in an opt-in, explicitly-experimental case, so I think it's relatively harmless to leave as-is for this PR.

As of a couple of recently-merged PRs (#180 and #181), the SDK now has a message bus that allows features to receive asynchronous notifications for things like RUM context changes, so the actual design would likely involve implementing MakeMessageHandler for Profiling, returning a function that handles ContextChangedMessage and takes the appropriate action when ctx.rum has changed.

That would obviate the need for SetContextChangeCallback (and direct coupling of features via the Core) entirely; but it's not pressing for this PR.

Comment thread src/datadog/impl/features/profiling/profiling.cpp Outdated
Comment thread src/datadog/impl/core/feature_types/rum.hpp Outdated
- remove interning of profiling config
- add more granular change detection on context changes
@r1viollet r1viollet force-pushed the r1viollet/profiling-integration branch from 044e1ed to c5f59c0 Compare March 17, 2026 16:50

Create a `.env` file in this directory (git-ignored):

```

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

for now we have some redundant config

@r1viollet r1viollet marked this pull request as ready for review March 17, 2026 17:01
@r1viollet r1viollet requested review from a team as code owners March 17, 2026 17:01
r1viollet and others added 2 commits March 17, 2026 18:07
- Skip SetRumSession when session hasn't changed
- Skip SetRumView when view hasn't changed
- Call ClearRumContext on session end (application_id == Zero)
- Cache UUID string representations to avoid repeated allocations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
joepeeples
joepeeples previously approved these changes Mar 17, 2026
// command; write the relevant UUIDs to the global RumFeatureContext, so that
// other features can enrich their events with RUM data
ctx.rum = rum->_application_snapshot.ToFeatureContext();
const RumFeatureContext new_context =

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this could be optimized further, for now there would be allocation on large view names

- cleanup const cast
- allow restart after stop
Comment thread include-c/datadog/core.h
DD_SITE_AP1,
DD_SITE_AP2,
DD_SITE_US1_FED,
DD_SITE_STAGING,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure we want to commit staging as client usable option....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm fine with leaving this out, we still need a good way for us to test, what would be the suggestion ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think I still had issues with getting the data in staging, even with this (the profiling data was fine though).
If you can deliver something that gets the data to staging, I'm happy to remove this part of the code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of adding a new site enum and calling config.SetSite(datadog::Site::staging) etc.; I think you could just do config.Internal_UseCustomEndpoint("https://browser-intake-datad0g.com") to circumvent site-based URL resolution entirely. Would that work for your needs?

Comment on lines +25 to +26
#ifdef DD_ENABLE_PROFILER
#include "datadog/impl/features/profiling/profiling.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll let you and Alex hash this out but I'd rather have this be DD_ENABLE_PROFILING only because DD_ENABLE_PROFILER sounds like we'll enabling profiling the SDK, not the enduser's application.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree, simply because we're calling the feature Profiling, so using that name verbatim feels clearer.

@awforsythe

Copy link
Copy Markdown
Contributor

It's been a while since the original base commit, and since then I've made a bunch of changes in main that have resulted in somewhat gnarly merge conflicts. Namely:

I didn't want to leave this PR in the lurch, so I made a copy of the branch (as aforsythe/rebase/profiling-integration), rebased it onto aforsythe/chore/reorganize-impl, resolved all the conflicts, and made sure it was building OK on Windows with -DDD_ENABLE_PROFILER=ON.

I don't have spare time at the moment to address any of the review notes, check that the smoke test is working, or implement the longer-term fix that's now possible thanks to the addition of a message bus (i.e. updating Profiling to handle ContextChangedMessage instead of having the Core directly wire Rum and Profiling together via a callback), but I'd be happy to take over some or all of those changes in the near future if needed.

In the meantime, let know if you'd like me to force-push my rebase back to origin/r1viollet/profiling-integration and help get this PR merged as-is.

@awforsythe

Copy link
Copy Markdown
Contributor

As we discussed in Slack: I'll open a new PR with my rebased changes. (It may be a day or two.)

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.

4 participants