[PROF-6071] Detect when libdatadog version does not match expected version#5484
Conversation
…rsion **What does this PR do?** This PR adds a runtime check to detect when the `libdatadog` gem version doesn't match the version that the native extensions were compiled against. When the `datadog` gem's native extensions are built, we now store the `libdatadog` version as a C preprocessor define (`EXPECTED_LIBDATADOG_VERSION`). At runtime, during extension initialization, we compare this against `Libdatadog::VERSION` and raise a helpful error if they don't match. **Motivation:** Fixes <#2242>. This is a rare but confusing issue that can happen when there are multiple `libdatadog` point releases that are compatible with the same `datadog` gem version. Historically this happened with `ddtrace` (the predecessor to the `datadog` gem) -- e.g. ddtrace 1.3.0 could use either libdatadog 0.7.0.1.0 or 0.7.0.1.1. In practice, no released version of the `datadog` gem has ever been affected by this issue, as each version pins to a specific libdatadog version with no other compatible releases. But this remains a useful defensive measure in case point releases are ever made in the future. **Change log entry** Yes. Core: Detect when `libdatadog` version does not match expected version. **Additional Notes:** I chose to use `rb_eval_string` to do the check since doing it in C is a lot more boilerplate and anyway this only happens once when an extension is loaded. **How to test the change?** Change includes test coverage. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Our existing begin/rescue code expects `LoadError`s.
BenchmarksBenchmark execution time: 2026-03-23 09:37:20 Comparing candidate commit 99db6f3 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 99db6f3 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Co-authored-by: Sergey Fedorov <[email protected]>
The quotation here needs to be part of the string since that's going into the `Makefile`. I missed this was subtly broken when we tried to avoid too-much-escaping.
What does this PR do?
This PR adds a runtime check to detect when the
libdatadoggem version doesn't match the version that the native extensions were compiled against.When the
datadoggem's native extensions are built, we now store thelibdatadogversion as a C preprocessor define (EXPECTED_LIBDATADOG_VERSION).At runtime, during extension initialization, we compare this against
Libdatadog::VERSIONand raise a helpful error if they don't match.Motivation:
Fixes #2242.
This is a rare but confusing issue that can happen when there are multiple
libdatadogpoint releases that are compatible with the samedatadoggem version. Historically this happened withddtrace(the predecessor to thedatadoggem) -- e.g. ddtrace 1.3.0 could use either libdatadog 0.7.0.1.0 or 0.7.0.1.1.In practice, no released version of the
datadoggem has ever been affected by this issue, as each version pins to a specific libdatadog version with no other compatible releases. But this remains a useful defensive measure in case point releases are ever made in the future.Change log entry
Yes. Core: Detect when
libdatadogversion does not match expected version.Additional Notes:
I chose to use
rb_eval_stringto do the check since doing it in C is a lot more boilerplate and anyway this only happens once when an extension is loaded.How to test the change?
Change includes test coverage.
I've also tested this locally by building a modern libdatadog with a dummy version: