Skip to content

Profiling: refactor AgentEndpoint so it can be const#3577

Merged
morrisonlevi merged 1 commit intomasterfrom
levi/const-agent-endpoint
Jan 15, 2026
Merged

Profiling: refactor AgentEndpoint so it can be const#3577
morrisonlevi merged 1 commit intomasterfrom
levi/const-agent-endpoint

Conversation

@morrisonlevi
Copy link
Copy Markdown
Collaborator

Description

This refactors AgentEndpoint to use a Cow<Path> instead of a PathBuf so that we can use &'static Path. This avoids an allocation which is a little bit nice, but mainly it's to allow us to make a const one:

AgentEndpoint::Socket(Cow::Borrowed(AgentEndpoint::DEFAULT_UNIX_SOCKET_PATH))

It's a little tricky to make a const &Path because Path::new isn't const, so it uses some unsafe tricks. Note that I ran this by miri locally and it was fine, as I expected.

This UDS path is not necessarily the "best" default because it's only partly true: in practice, we use this as the default agent path if it exists, but if it doesn't, then we use "http://localhost:8126". But it has the distinct advantage of being one that can be defined in const contexts. I plan to use this in another PR to simplify SystemSettings.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@morrisonlevi morrisonlevi requested a review from a team as a code owner January 15, 2026 04:44
@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented Jan 15, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1022 Tests failed

    testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Fix with Cursor)

    testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Fix with Cursor)

testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 6968709b000000009b60fe79fae009d1
tid: 6968709b00000000
hexProcessTraceId: 9b60fe79fae009d1
hexProcessSpanId: 4def87904ae9f7eb
processTraceId: 11196228473496537553
processSpanId: 5615856314156185579

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4e3890b | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@github-actions github-actions Bot added profiling Relates to the Continuous Profiler tracing labels Jan 15, 2026
Copy link
Copy Markdown
Member

@realFlowControl realFlowControl left a comment

Choose a reason for hiding this comment

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

If I see this right, in conjunction with #3578, AgentEndpoint (specifically the PathBuf inside) is the sole reason why SystemSettings is not const and why we are using the MaybeUninit thing there and this PR unlocks the path to make SystemSettings const.
Nice!

@morrisonlevi morrisonlevi merged commit ed3089e into master Jan 15, 2026
2004 of 2009 checks passed
@morrisonlevi morrisonlevi deleted the levi/const-agent-endpoint branch January 15, 2026 12:58
@github-actions github-actions Bot added this to the 1.16.0 milestone Jan 15, 2026
@morrisonlevi
Copy link
Copy Markdown
Collaborator Author

Yes, that's right. This should make things safer and easier to work with!

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.

2 participants