Skip to content

chore: compute ddtrace version dynamically from git state - #19697

Draft
P403n1x87 wants to merge 1 commit into
mainfrom
chore/infer-next-release-version
Draft

chore: compute ddtrace version dynamically from git state#19697
P403n1x87 wants to merge 1 commit into
mainfrom
chore/infer-next-release-version

Conversation

@P403n1x87

Copy link
Copy Markdown
Collaborator

Description

Replace setuptools_scm's abandoned release-branch-semver scheme (broken by detached-HEAD branch detection) and the manual version-bump PR process with scripts/compute_version.py: a dependency-free script that derives PEP 440 versions from git tags/branches, using explicit CI-provided ref info (never git rev-parse --abbrev-ref HEAD alone) and ancestry-independent global tag comparison for main's "latest shipped release" (release branches never merge back, so ancestry-based lookup misses sibling-branch releases).

Validated so far:

  • Unit tests against synthetic git repos (tests/scripts/test_compute_version.py), covering all 4 version rules, detached HEAD, GH/GitLab ref resolution, and the main-after-sibling-branch-release regression case.
  • Historical replay against this repo's real git history (via disposable worktrees) for rules 1-3: exact tag builds, release-branch patch/dev versions, and freshly-cut release branches all matched expected output.

Still outstanding before this can be trusted in production CI:

  • Cross-CI determinism: confirm GitHub Actions and GitLab CI resolve the same branch name and produce an identical version string for the same commit.
  • cibuildwheel's manylinux/musllinux containers: verify git is available (needed since setup.py recomputes the version inside those containers too).
  • sdist-then-wheel round trip: confirm ddtrace/_version_frozen.py, written when git is available, is correctly read back when a wheel is built from an sdist with no .git present.
  • GIT_DEPTH: "0" on the GitLab package/build jobs: confirm against a live pipeline that full tag history is actually fetched (rule 4's global tag scan needs it).

@P403n1x87 P403n1x87 added the changelog/no-changelog A changelog entry is not required for this PR. label Aug 14, 2026
@P403n1x87 P403n1x87 changed the title feat(build): compute ddtrace version dynamically from git state chore: compute ddtrace version dynamically from git state Aug 14, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 14, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 6 circular imports that already exist on the base branch and have not been changed by this PR.

Show existing cycles (showing 5 of 6 shortest)
ddtrace.contrib.internal.django.patch -> ddtrace.contrib.internal.django.response -> ddtrace.contrib.internal.django.patch
ddtrace.contrib.internal.pytorch._distributed -> ddtrace.contrib.internal.pytorch._rank_root -> ddtrace.contrib.internal.pytorch._distributed
ddtrace.appsec._common_module_patches -> ddtrace.appsec._listeners -> ddtrace.appsec._common_module_patches
ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs

To see all cycles, download the cycles-base.json and cycles-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/cycles.py compare cycles-base.json cycles-pr.json

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 14, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 256 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 256 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._integrations.anthropic -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.claude_agent_sdk -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.langchain -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._utils -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 10 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v126532274-233089d-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64]   View in Datadog   GitLab

View all 10 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4eb5edd | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.gitignore                                                              @DataDog/apm-core-python
.gitlab/package.yml                                                     @DataDog/python-guild @DataDog/apm-core-python
.gitlab/templates/cached-testrunner.yml                                 @DataDog/python-guild @DataDog/apm-core-python
docs/contributing-release.rst                                           @DataDog/python-guild
pyproject.toml                                                          @DataDog/python-guild
scripts/check_suitespec_coverage.py                                     @DataDog/python-guild
scripts/compute_version.py                                              @DataDog/python-guild
scripts/gen_gitlab_config.py                                            @DataDog/python-guild
scripts/resolve_previous_version.py                                     @DataDog/python-guild
scripts/run-script-doctests.py                                          @DataDog/python-guild
scripts/verify-package-version                                          @DataDog/python-guild
scripts/version_lib.py                                                  @DataDog/python-guild
setup.py                                                                @DataDog/python-guild
tests/scripts/test_compute_version.py                                   @DataDog/apm-core-python

@pr-commenter

pr-commenter Bot commented Aug 14, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-14 13:02:12

Comparing candidate commit 4eb5edd in PR branch chore/infer-next-release-version with baseline commit 1e220c0 in branch main.

Found 0 performance improvements and 5 performance regressions! Performance is the same for 616 metrics, 10 unstable metrics.

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+2.835µs; +3.027µs] or [+13.896%; +14.838%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+106.309µs; +112.643µs] or [+26.414%; +27.988%]

scenario:span-start

  • 🟥 execution_time [+1.270ms; +1.438ms] or [+7.842%; +8.881%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+626.889ns; +660.438ns] or [+24.489%; +25.800%]

scenario:tracer-small

  • 🟥 execution_time [+26.382µs; +28.876µs] or [+7.405%; +8.105%]

Replace setuptools_scm's abandoned release-branch-semver scheme (broken by
detached-HEAD branch detection) and the manual version-bump PR process with
scripts/compute_version.py: a dependency-free script that derives PEP 440
versions from git tags/branches, using explicit CI-provided ref info (never
`git rev-parse --abbrev-ref HEAD` alone) and ancestry-independent global tag
comparison for main's "latest shipped release" (release branches never merge
back, so ancestry-based lookup misses sibling-branch releases).

Validated so far:
- Unit tests against synthetic git repos (tests/scripts/test_compute_version.py),
  covering all 4 version rules, detached HEAD, GH/GitLab ref resolution, and the
  main-after-sibling-branch-release regression case.
- Historical replay against this repo's real git history (via disposable
  worktrees) for rules 1-3: exact tag builds, release-branch patch/dev
  versions, and freshly-cut release branches all matched expected output.

Still outstanding before this can be trusted in production CI:
- Cross-CI determinism: confirm GitHub Actions and GitLab CI resolve the same
  branch name and produce an identical version string for the same commit.
- cibuildwheel's manylinux/musllinux containers: verify `git` is available
  (needed since setup.py recomputes the version inside those containers too).
- sdist-then-wheel round trip: confirm ddtrace/_version_frozen.py, written
  when git is available, is correctly read back when a wheel is built from an
  sdist with no .git present.
- GIT_DEPTH: "0" on the GitLab package/build jobs: confirm against a live
  pipeline that full tag history is actually fetched (rule 4's global tag scan
  needs it).

Pre-commit hooks (mypy, bandit) skipped for this commit with explicit sign-off:
both are triggered by pre-existing, unrelated issues in scripts/gen_gitlab_config.py's
import graph (tests/suitespec.py, scripts/needs_testrun.py) that predate this
change and are outside mypy.ini's official `files = ddtrace, docs` scope, plus
expected Low-severity bandit findings on this script's inherent subprocess/assert
usage.
@P403n1x87
P403n1x87 force-pushed the chore/infer-next-release-version branch from dce996f to 4eb5edd Compare August 14, 2026 12:37
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.

1 participant