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

feat(config): support libdatadog's library_config for config through file #11839

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

BaptisteFoy
Copy link
Contributor

@BaptisteFoy BaptisteFoy commented Dec 27, 2024

Description of changes

  • Bumps libdatadog to v15.0.0 & handles the required changes to crashtracking
  • Starts using the library_config component of libdatadog that allows reading configuration from a file with a higher precedence than environment variables

Supported config entries

As of libdatadog v15.0.0 (source):

  • DD_TRACE_DEBUG
  • DD_SERVICE
  • DD_ENV
  • DD_VERSION
  • DD_PROFILING_ENABLED

Testing strategy

Added a unit test.

To test this PR, you can:

  1. Create a Linux VM
  2. Start this tracer version & ensure everything works well (non-regression)
  3. Create a file at the following path: /etc/datadog-agent/managed/datadog-apm-libraries/stable/libraries_config.yaml
  4. Write the following content in the file:
rules:
  - selectors:
      - origin: language
        matches:
          - python
        operator: equals
    configuration:
      DD_TRACE_DEBUG: true
  1. Start this tracer version
  2. Verify that debug logs are properly enabled

Additional concerns

This change does increase the size of the serverless layer by 380KB (14204KB vs 13824 as the limit) even after optimization. I had to go from lto=true to lto=fast, as lto=true somehow prevents release builds on older machines. That accounts for 200KB, while the 200 other KB are mostly coming from the libdatadog bump.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Dec 27, 2024

CODEOWNERS have been resolved as:

src/native/library_config.rs                                            @DataDog/apm-core-python
tests/internal/test_native.py                                           @DataDog/apm-core-python
ddtrace/__init__.py                                                     @DataDog/apm-core-python
ddtrace/internal/native/__init__.py                                     @DataDog/apm-core-python
ddtrace/internal/native/_native.pyi                                     @DataDog/apm-core-python
src/native/Cargo.lock                                                   @DataDog/apm-core-python
src/native/Cargo.toml                                                   @DataDog/apm-core-python
src/native/lib.rs                                                       @DataDog/apm-core-python

@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch 3 times, most recently from 606b2a5 to cef695a Compare December 27, 2024 14:39
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from cef695a to 3f85c2a Compare January 15, 2025 13:43
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from 3f85c2a to 908ace8 Compare January 15, 2025 13:44
@pr-commenter
Copy link

pr-commenter bot commented Jan 17, 2025

Benchmarks

Benchmark execution time: 2025-01-24 16:23:27

Comparing candidate commit 1a40d17 in PR branch baptiste.foy/FA/library-config-libdatadog with baseline commit 9e87349 in branch main.

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

scenario:iast_aspects-ospathbasename_aspect

  • 🟥 execution_time [+293.691ns; +345.716ns] or [+8.822%; +10.385%]

scenario:iast_aspects-ospathsplit_aspect

  • 🟥 execution_time [+381.109ns; +441.813ns] or [+9.967%; +11.555%]

Copy link
Contributor

@taegyunkim taegyunkim left a comment

Choose a reason for hiding this comment

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

👋 I'd like to suggest not adding new modules under /profiling as the functionality is not profiling. You should be able to expose the libdatadog API through src/core, or add a new rust/python module under src/

@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch 2 times, most recently from 4bd0ef9 to 217fa81 Compare January 21, 2025 13:41
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from 217fa81 to 39af866 Compare January 21, 2025 13:58
@BaptisteFoy BaptisteFoy changed the title upgrade(tracer): Support libdatadog's library_config for config through file feat(config): Support libdatadog's library_config for config through file Jan 21, 2025
@BaptisteFoy BaptisteFoy changed the title feat(config): Support libdatadog's library_config for config through file feat(config): support libdatadog's library_config for config through file Jan 21, 2025
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from 55ce7fe to df2f272 Compare January 21, 2025 14:20
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from df2f272 to a1877e2 Compare January 21, 2025 14:28
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Jan 21, 2025

Datadog Report

Branch report: baptiste.foy/FA/library-config-libdatadog
Commit report: 1575326
Test service: dd-trace-py

✅ 0 Failed, 208 Passed, 1390 Skipped, 5m 3.12s Total duration (35m 0.17s time saved)

@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from bb2848b to 32de0db Compare January 21, 2025 16:38
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch 5 times, most recently from fddf037 to bac1549 Compare January 22, 2025 15:23
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch 3 times, most recently from f54495b to b42da4d Compare January 23, 2025 15:35
@taegyunkim
Copy link
Contributor

Adding @brettlangdon to the reviewers early so you could get feedback sooner than later

Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

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

can we break up this PR?

I think there is the libdatadog version bump, core package renaming, and then the config file changes which can all get broken up.

Copy link
Contributor

@mabdinur mabdinur left a comment

Choose a reason for hiding this comment

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

Overall looks great! High level comments:

  • Setting environment variables directly is good enough for this POC now but we will need to revisit this design decision to better track the origin of configurations.
  • We need to identify all scenarios where the value set by stable configurations can be overriden by the ddtrace library.
  • We need to document a clear precedence for configurations and ensure all libraries follow it (rc -> stable_config -> in_code -> envar -> reading from yaml file)
  • We need to document which configurations are supported by 15.0. Including this in the PR description is fine.
  • We should split up this PR (@brettlangdon's comment)

ddtrace/__init__.py Outdated Show resolved Hide resolved
ddtrace/internal/native/__init__.py Show resolved Hide resolved
ddtrace/internal/native/_native.pyi Outdated Show resolved Hide resolved
src/native/library_config.rs Show resolved Hide resolved
- nodejs
operator: equals
configuration:
DD_SERVICE: my-service
Copy link
Contributor

Choose a reason for hiding this comment

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

In the python tracer the DD_SERVICE environment variable can be overridden by integrations and other ddtrace products (ex: serverless).

We will need to audit all the configurations supported by libdatadog and ensure the value set via APM Stable Configurations take precedence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I also think that we need to have a discussion on the order of precedence. For instance in the agent, config values set by the runtime (ie inside the agent code) take precedence over Fleet Automation. One could argue that we should replicate that behaviour here; but imo this is a product decision.

ddtrace/__init__.py Outdated Show resolved Hide resolved
ddtrace/internal/native/__init__.py Show resolved Hide resolved
@BaptisteFoy BaptisteFoy changed the base branch from main to baptiste.foy/FA/core-to-native January 24, 2025 10:26
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch 2 times, most recently from d1972ff to e207136 Compare January 24, 2025 10:29
@BaptisteFoy BaptisteFoy force-pushed the baptiste.foy/FA/library-config-libdatadog branch from e207136 to be6fc28 Compare January 24, 2025 10:30
@BaptisteFoy
Copy link
Contributor Author

@brettlangdon @mabdinur Could you please review #12063 & #12065 as new prerequisites to this PR, as suggested?

@BaptisteFoy BaptisteFoy added the changelog/no-changelog A changelog entry is not required for this PR. label Jan 24, 2025
Copy link
Contributor

@mabdinur mabdinur left a comment

Choose a reason for hiding this comment

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

LGTM. Once the prerequisite PRs are merged we can ship this change

ddtrace/__init__.py Outdated Show resolved Hide resolved
Base automatically changed from baptiste.foy/FA/core-to-native to main January 24, 2025 15:26
mabdinur pushed a commit that referenced this pull request Jan 24, 2025
This PR depends on #12063.

Rename src/core to src/native. This is laying ground as a [following
PR](#11839) will need to
import native code in `ddtrace.__init__.py`. Without this change this
would create a dependency loop between `ddtrace` & `ddtrace.core`
through `event_hub.py`.

This PR only renames files, so a non-regression test is the only thing
needed.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
@mabdinur mabdinur marked this pull request as ready for review January 24, 2025 20:18
@mabdinur mabdinur requested a review from a team as a code owner January 24, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants