Skip to content

feat(prof): add source code integration#3418

Merged
morrisonlevi merged 5 commits into
masterfrom
florian/source-code-integration
Sep 23, 2025
Merged

feat(prof): add source code integration#3418
morrisonlevi merged 5 commits into
masterfrom
florian/source-code-integration

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Sep 17, 2025

Copy link
Copy Markdown
Member

Description

This adds source code integration feature to the PHP profiler via the environment variables DD_GIT_COMMIT_SHA and DD_GIT_REPOSITORY_URL or the equivalent INI settings datadog.git_commit_sha and datadog.git_repository_url. You can already use this feature via the DD_TAGS environment variable.

image

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

PROF-12551

@github-actions github-actions Bot added profiling Relates to the Continuous Profiler tracing labels Sep 17, 2025
@codecov-commenter

codecov-commenter commented Sep 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.74%. Comparing base (b8bf258) to head (55850d4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3418      +/-   ##
==========================================
- Coverage   61.90%   61.74%   -0.17%     
==========================================
  Files         141      141              
  Lines       12481    12481              
  Branches     1630     1630              
==========================================
- Hits         7726     7706      -20     
- Misses       4033     4054      +21     
+ Partials      722      721       -1     

see 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8bf258...55850d4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter

pr-commenter Bot commented Sep 17, 2025

Copy link
Copy Markdown

Benchmarks [ profiler ]

Benchmark execution time: 2025-09-22 07:14:14

Comparing candidate commit 55850d4 in PR branch florian/source-code-integration with baseline commit b8bf258 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 5 unstable metrics.

@realFlowControl
realFlowControl force-pushed the florian/source-code-integration branch from a0b954a to b642c03 Compare September 17, 2025 15:09
@realFlowControl
realFlowControl marked this pull request as ready for review September 17, 2025 15:11
@realFlowControl
realFlowControl requested a review from a team as a code owner September 17, 2025 15:11
@morrisonlevi morrisonlevi changed the title feat(prof) add source code integration feat(prof): add source code integration Sep 17, 2025

@morrisonlevi morrisonlevi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't integrate with the config module, so users cannot use INIs to configure this. That also means our datadog-setup.php config mode won't work with it either.

If we agree it should be done, then add these two variants to the ConfigId enum:

    GitCommitSha,
    GitRepositoryUrl,

Add some functions like:

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn git_commit_sha() -> Option<String> {
    get_str(Env)
}

/// # Safety
/// This function must only be called after config has been initialized in
/// rinit, and before it is uninitialized in mshutdown.
pub(crate) unsafe fn git_repository_url() -> Option<String> {
    get_str(Env)
}

Add it to the ENTRIES array:

                zai_config_entry {
                    id: transmute::<ConfigId, u16>(GitCommitSha),
                    name: Env.env_var_name(),
                    type_: ZAI_CONFIG_TYPE_STRING,
                    default_encoded_value: ZaiStr::new(),
                    aliases: ptr::null_mut(),
                    aliases_count: 0,
                    ini_change: None,
                    parser: Some(parse_utf8_string),
                    displayer: None,
                    env_config_fallback: None,
                },
                zai_config_entry {
                    id: transmute::<ConfigId, u16>(GitRepositoryUrl),
                    name: Env.env_var_name(),
                    type_: ZAI_CONFIG_TYPE_STRING,
                    default_encoded_value: ZaiStr::new(),
                    aliases: ptr::null_mut(),
                    aliases_count: 0,
                    ini_change: None,
                    parser: Some(parse_utf8_string),
                    displayer: None,
                    env_config_fallback: None,
                },

Add it to the env_var_name match:

            GitCommitSha => b"DD_GIT_COMMIT_SHA\0",
            GitRepositoryUrl => c"DD_GIT_REPOSITORY_URL\0",

And add it to the test cases for names:

            (b"DD_GIT_COMMIT_SHA\0", "datadog.git_commit_sha"),
            (b"DD_GIT_REPOSITORY_URL\0", "datadog.git_repository_url"),

@morrisonlevi morrisonlevi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, I think maybe it should be moved to the part where service, env, and version are handled. Theoretically you could change files and reconfigure, yeah? At least the tracer didn't register this as a system INI. What do you think?

@realFlowControl

Copy link
Copy Markdown
Member Author

I did the changes towards this, especially that it makes the feature symmetric with the tracer

@morrisonlevi
morrisonlevi merged commit f32784c into master Sep 23, 2025
16 of 17 checks passed
@morrisonlevi
morrisonlevi deleted the florian/source-code-integration branch September 23, 2025 18:56
@github-actions github-actions Bot added this to the 1.13.0 milestone Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Relates to the Continuous Profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants