Skip to content
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

[PROF-8917] Add Ruby helper to get ld_library_path for libdatadog #423

Merged
merged 2 commits into from
May 10, 2024

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented May 9, 2024

What does this PR do?

This PR adds a Libdatadog.ld_library_path helper to the libdatadog Ruby support code.

This helper returns the full path to the lib/ folder where the libdatadog .so files are contained.

Motivation

I'm adding this to support the crashtracker for Ruby: we need this information when starting the crashtracker, and rather than having the knowledge of folder layouts inside dd-trace-rb, I think it makes sense for the libdatadog Ruby code to keep this knowledge.

Additional Notes

I'm planning to include this change in the libdatadog 9 release for Ruby.

How to test the change?

Test coverage is included (and CI runs these tests).

**What does this PR do?**

This PR adds a `Libdatadog.ld_library_path` helper to the libdatadog
Ruby support code.

This helper returns the full path to the `lib/` folder where the
libdatadog `.so` files are contained.

**Motivation:**

I'm adding this to support the crashtracker for Ruby: we need this
information when starting the crashtracker, and rather than having
the knowledge of folder layouts inside dd-trace-rb, I think it
makes sense for the libdatadog Ruby code to keep this knowledge.

**Additional Notes:**

I'm planning to include this change in the libdatadog 9 release
for Ruby.

**How to test the change?**

Test coverage is included (and CI runs these tests).
@ivoanjo ivoanjo requested a review from a team as a code owner May 9, 2024 14:41
@ivoanjo ivoanjo requested a review from a team May 9, 2024 14:41
@codecov-commenter
Copy link

codecov-commenter commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.36%. Comparing base (0d74198) to head (a87bfa0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #423   +/-   ##
=======================================
  Coverage   65.36%   65.36%           
=======================================
  Files         184      184           
  Lines       22503    22503           
=======================================
  Hits        14710    14710           
  Misses       7793     7793           
Components Coverage Δ
crashtracker 20.31% <ø> (ø)
data-pipeline 51.45% <ø> (ø)
data-pipeline-ffi 0.00% <ø> (ø)
ddcommon 81.23% <ø> (ø)
ddcommon-ffi 74.93% <ø> (ø)
ddtelemetry 53.72% <ø> (ø)
ipc 81.27% <ø> (ø)
profiling 76.89% <ø> (ø)
profiling-ffi 60.05% <ø> (ø)
serverless 0.00% <ø> (ø)
sidecar 29.37% <ø> (ø)
sidecar-ffi 0.00% <ø> (ø)
spawn-worker 54.98% <ø> (ø)
trace-mini-agent 69.12% <ø> (ø)
trace-normalization 97.79% <ø> (ø)
trace-obfuscation 95.74% <ø> (ø)
trace-protobuf 25.64% <ø> (ø)
trace-utils 68.85% <ø> (ø)

ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request May 9, 2024
This will be integrated into the libdatadog v9 release in
DataDog/libdatadog#423 .

return unless pkgconfig_folder

File.absolute_path("#{pkgconfig_folder}/../")
Copy link
Contributor

Choose a reason for hiding this comment

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

I trust you know what you are doing... 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahaha thanks! To be clear, what this does is take the structure of our binary builds:

% tree
.
├── bin
│   └── libdatadog-crashtracking-receiver
├── cmake
│   └── DatadogConfig.cmake
├── include
│   └── datadog
│       ├── blazesym.h
│       ├── common.h
│       ├── profiling.h
│       └── telemetry.h
├── lib
│   ├── libdatadog_profiling.a
│   ├── libdatadog_profiling.so
│   ├── libdatadog_profiling.so.debug
│   └── pkgconfig
│       ├── datadog_profiling.pc
│       ├── datadog_profiling-static.pc
│       └── datadog_profiling_with_rpath.pc
├── LICENSE
├── LICENSE-3rdparty.yml
└── NOTICE

and encodes the knowledge that the .so file is in the parent folder to the pkgconfig file.

I could've implemented this another way (e.g. search for the so file directly or something), but since this is internal to the libdatadog helper, and we already have another helper that does this relative find thing, I just went with it.

(Since on the Ruby library side we only call these methods and don't encode any assumptions on the folder structure, we can always update the helpers and move stuff around whenever we want to).

@ivoanjo ivoanjo merged commit 3780d6d into main May 10, 2024
25 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/add-ruby-folder-helper branch May 10, 2024 10:31
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.

3 participants