-
Notifications
You must be signed in to change notification settings - Fork 490
feat: store OTEL process context in named anonymous mapping on Linux #3937
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
base: main
Are you sure you want to change the base?
Conversation
0cd2733 to
99d1142
Compare
BenchmarksBenchmark execution time: 2025-11-17 11:33:34 Comparing candidate commit 76e24fe in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics. |
f4348e8 to
56e26fa
Compare
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.
Left a couple of comments!
My go-foo is not very strong so definitely worth getting a pass from someone that's not pretending to know go as well ;)
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.
Oh, this is cool! Much better than generating this by hand as we did in the C implementation ;)
2282839 to
3025072
Compare
nsrip-dd
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.
I've tested this with a simple Go program that just starts the APM tracer and then blocks forever. I've set DD_ENV, service name, and other config values, and then used Ivo's shell script to confirm that the memory mapping is there and has the expected contents.
Just left a few small comments.
ddtrace/tracer/otelprocesscontext.go
Outdated
| // https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-version | ||
| ServiceVersion string `msg:"service.version"` | ||
| // https://opentelemetry.io/docs/specs/semconv/registry/attributes/telemetry/#telemetry-sdk-language | ||
| TelemetrySdkLanguage string `msg:"telemetry.sdk.language"` |
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 small nitpick: the Go custom is to capitalize acronyms, like TelemetrySDKLanguage
| log.Error("failed to store the configuration: %s", err.Error()) | ||
| } | ||
|
|
||
| processContext := otelProcessContext{ |
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.
Do we have a doc that explains why were are not using the Memfd solution for OpenTelemetry? IIRC we had some good reason, but I forgot what it was. We should probably link to that doc here.
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.
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.
The main reasons were:
memfd_createsyscall might be blocked by some seccomp profiles- it requires more syscalls / IO since all symlinks in
/proc/<pid>/fd/need to be resolved untildatadog-tracer-info-<id>file is found
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.
The "not inherited by fork" is also a nice bonus, and connects back to the discussions happening internally on the meaning of "runtime-id" -- the anonymous mapping mechanism, because it's not inherited by forks won't have any issues with stale information (such as a runtime-id) being carried from parent to child process.
d14c0bc to
0111ebb
Compare
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2025 Datadog, Inc. | ||
|
|
||
| //go:build linux |
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.
I know this is a Linux specific implementation, but it'd be good to have some tests. You can skip a test if the OS isn't Linux like this:
func TestCreateOtelProcessContextMapping(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("OTEL process context mapping is only supported on Linux")
}
}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.
I was reluctant to add a test because of all the code needed to read the mapping.
But so be it, I added a test.
e5bd886 to
76e24fe
Compare
|
@darccio would you have time for this review ? 🙇 |
What does this PR do?
This PR stores the tracer process level context in a named anonymous mapping on Linux.
PROF-12406
Motivation
Project plan
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!