Skip to content

Commit

Permalink
refactor(core): move src/core to src/native (#12065)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
BaptisteFoy authored Jan 24, 2025
1 parent 7669493 commit 9e87349
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
extension: ["src/core"]
extension: ["src/native"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 0 additions & 1 deletion ddtrace/internal/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def _on_jsonify_context_started_flask(ctx):

from ..utils.deprecations import DDTraceDeprecationWarning
from . import event_hub # noqa:F401
from ._core import DDSketch # noqa:F401
from .event_hub import EventResultDict # noqa:F401
from .event_hub import dispatch
from .event_hub import dispatch_with_results # noqa:F401
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/internal/datastreams/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ddtrace.internal import compat
from ddtrace.internal.atexit import register_on_exit_signal
from ddtrace.internal.constants import DEFAULT_SERVICE_NAME
from ddtrace.internal.core import DDSketch
from ddtrace.internal.native import DDSketch
from ddtrace.internal.utils.retry import fibonacci_backoff_with_jitter

from .._encoding import packb
Expand Down
1 change: 1 addition & 0 deletions ddtrace/internal/native/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._native import DDSketch # noqa: F401
File renamed without changes.
2 changes: 1 addition & 1 deletion ddtrace/internal/processor/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ddtrace._trace.processor import SpanProcessor
from ddtrace._trace.span import _is_top_level
from ddtrace.internal import compat
from ddtrace.internal.core import DDSketch
from ddtrace.internal.native import DDSketch
from ddtrace.internal.utils.retry import fibonacci_backoff_with_jitter

from ...constants import SPAN_MEASURED_KEY
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

LIBDDWAF_VERSION = "1.22.0"

# DEV: update this accordingly when src/core upgrades libdatadog dependency.
# DEV: update this accordingly when src/native upgrades libdatadog dependency.
# libdatadog v15.0.0 requires rust 1.78.
RUST_MINIMUM_VERSION = "1.78"

Expand Down Expand Up @@ -660,8 +660,8 @@ def get_exts_for(name):
+ get_exts_for("psutil"),
rust_extensions=[
RustExtension(
"ddtrace.internal.core._core",
path="src/core/Cargo.toml",
"ddtrace.internal.native._native",
path="src/native/Cargo.toml",
py_limited_api="auto",
binding=Binding.PyO3,
debug=os.getenv("_DD_RUSTC_DEBUG") == "1",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/core/Cargo.toml → src/native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ddtrace-core"
name = "ddtrace-native"
version = "0.1.0"
edition = "2021"

Expand All @@ -16,7 +16,7 @@ datadog-ddsketch = { git = "https://github.com/DataDog/libdatadog", rev = "v15.0
pyo3-build-config = "0.21.2"

[lib]
name = "_core"
name = "_native"
path = "lib.rs"
crate-type = ["cdylib"]

Expand Down
2 changes: 1 addition & 1 deletion src/core/ddsketch.rs → src/native/ddsketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pyo3::types::PyBytes;

use datadog_ddsketch::DDSketch;

#[pyclass(name = "DDSketch", module = "ddtrace.internal._core")]
#[pyclass(name = "DDSketch", module = "ddtrace.internal._native")]
pub struct DDSketchPy {
ddsketch: DDSketch,
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib.rs → src/native/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod ddsketch;
use pyo3::prelude::*;

#[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
fn _native(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<ddsketch::DDSketchPy>()?;
Ok(())
}
3 changes: 2 additions & 1 deletion tests/suitespec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ components:
- ddtrace/internal/logger.py
- ddtrace/internal/metrics.py
- ddtrace/internal/module.py
- ddtrace/internal/native/*
- ddtrace/internal/packages.py
- ddtrace/internal/third-party.tar.gz
- ddtrace/internal/periodic.py
Expand All @@ -76,7 +77,7 @@ components:
- ddtrace/py.typed
- ddtrace/version.py
- ddtrace/settings/config.py
- src/core/*
- src/native/*
datastreams:
- ddtrace/internal/datastreams/*
- ddtrace/data_streams.py
Expand Down

0 comments on commit 9e87349

Please sign in to comment.