Skip to content

feat: store tracer configuration in an in-memory file #3171

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

Merged
merged 6 commits into from
Mar 7, 2025

Conversation

dmehala
Copy link
Contributor

@dmehala dmehala commented Feb 10, 2025

What does this PR do?

This is PR store the tracer configuration in an memfd file.

APMAPI-1070

Motivation

Process Discovery.

Note to reviewers

Sorry, I am not well-versed in Go. Please feel free to take over the pull request to ensure it aligns more closely with idiomatic practices and fits better within the codebase.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 10, 2025

Datadog Report

Branch report: dmehala/feat/process-discovery
Commit report: 09fcf6f
Test service: dd-trace-go

✅ 0 Failed, 5386 Passed, 73 Skipped, 2m 48.75s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Feb 10, 2025

Benchmarks

Benchmark execution time: 2025-03-07 14:03:29

Comparing candidate commit b4c3297 in PR branch dmehala/feat/process-discovery with baseline commit 0e4174c in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 59 metrics, 2 unstable metrics.

scenario:BenchmarkStartRequestSpan-24

  • 🟥 execution_time [+58.851ns; +60.109ns] or [+12.936%; +13.213%]

@dmehala dmehala force-pushed the dmehala/feat/process-discovery branch from 9ba3247 to f6a9d79 Compare February 11, 2025 14:40
@dmehala dmehala marked this pull request as ready for review February 11, 2025 14:43
@dmehala dmehala requested review from a team as code owners February 11, 2025 14:43

metadata := TracerMetadata{
SchemaVersion: 1,
RuntimeId: "TBD", ///< Where to get it?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need guidance here on how to get this the runtimeID.

Copy link
Member

Choose a reason for hiding this comment

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

globalconfig.RuntimeID()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 7bb75db

SchemaVersion: 1,
RuntimeId: "TBD", ///< Where to get it?
Language: "golang",
Version: "1.2.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

Copy link
Member

Choose a reason for hiding this comment

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

For the tracer's version, it's in internal/version.Tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 7bb75db

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

Could you provide some context? What's the goal and intended use case for storing the config in an in-memory file?

@dmehala
Copy link
Contributor Author

dmehala commented Feb 12, 2025

@kakkoyun Process Discovery.

@dmehala dmehala requested a review from darccio February 13, 2025 16:42
Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

We should implement testing for this covering the different situations. You can use runtime.GOOS == "linux" to run the test only in Linux.


metadata := TracerMetadata{
SchemaVersion: 1,
RuntimeId: "TBD", ///< Where to get it?
Copy link
Member

Choose a reason for hiding this comment

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

globalconfig.RuntimeID()

SchemaVersion: 1,
RuntimeId: "TBD", ///< Where to get it?
Language: "golang",
Version: "1.2.3",
Copy link
Member

Choose a reason for hiding this comment

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

For the tracer's version, it's in internal/version.Tag.

@dmehala dmehala requested review from darccio and kakkoyun February 21, 2025 11:20
@dmehala
Copy link
Contributor Author

dmehala commented Feb 21, 2025

We should implement testing for this covering the different situations. You can use runtime.GOOS == "linux" to run the test only in Linux.

Unless I mock the syscall, I am afraid this not very testable. Do you have anything else in mind @darccio?

@darccio
Copy link
Member

darccio commented Feb 24, 2025

@dmehala Why do you need to mock the call?

@dmehala
Copy link
Contributor Author

dmehala commented Feb 26, 2025

@darccio Well, if the goal is to check that the memfd is created and contains the correct value, we already have a system test for that. Would that be enough, or are you looking for something more?

@darccio
Copy link
Member

darccio commented Mar 7, 2025

@dmehala If we have a system test for this, let's go forward.

@darccio darccio merged commit 4800665 into main Mar 7, 2025
176 checks passed
@darccio darccio deleted the dmehala/feat/process-discovery branch March 7, 2025 14:18
Comment on lines +214 to +217
// store the configuration in an in-memory file, allowing it to be read to
// determine if the process is instrumented with a tracer and to retrive
// relevant tracing information.
storeConfig(t.config)
Copy link
Member

Choose a reason for hiding this comment

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

👋 I came across the code in this PR (and the RFC for it) today. It's really cool. I didn't know about the memfd syscalls - I might have some use cases for it in the future as well!

Anyway, I'm commenting b/c I think there is a slight problem here. This code is only considering the tracer product. I think there is a problem when a customer is only enabling the profiler, but not the tracer. This does happen sometimes in the real world AFAIK.

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