Skip to content

Conversation

@taegyunkim
Copy link
Contributor

@taegyunkim taegyunkim commented Nov 7, 2025

Description

Remove Python Profiler v1 implementation, and clean up test suites.

One of the notable improvements from this PR is that StackCollector no longer spawns an extra background thread by inheriting from Collector instead of PeriodicService. Also, ddtrace/profiling/collector/stack.pyx has been de-cythonized as it now is a simple wrapper around stack_v2 native extension module.

Testing

Risks

Additional Notes

emmettbutler and others added 30 commits October 17, 2025 18:22
This change removes the `cassandra` contrib package, which is only
tested on the to-be-removed Python 3.8 runtime.
## Motivation

The mongoengine integration does not generate any spans and only
supports attaching a Pin object to the underlying pymongo client. Since
we're deprecating the Pin mechanism and pymongo already fully supports
the needed functionality, maintaining the mongoengine integration is
redundant.

## Description

This PR removes the mongoengine integration from ddtrace. The pymongo
integration, which is enabled by default, will continue to provide
tracing for applications using mongoengine, as mongoengine internally
uses pymongo.
The only notable change is that users can no longer set a Pin on the
mongoengine client. Instead, they should configure the Pin directly on
the pymongo client if needed. Support for the Pin API will be removed in
a future release.

## 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
- [ ] 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)
This change removes the deprecated `opentracer` package from ddtrace.

Note the base branch, a staging area for breaking changes slated for
4.0.

---------

Co-authored-by: brettlangdon <[email protected]>
This change removes deprecated methods and method parameters from the
`Span` class.

Note the base branch, a staging area for breaking changes slated for
4.0.

---------

Co-authored-by: brettlangdon <[email protected]>
This change removes support and testing for Python 3.8, which reached
its end-of-life in late 2024 and was deprecated in ddtrace in
#14890. It also deprecates
support for Python 3.9, which reached its end-of-life recently.

This includes removal of the `cassandra` integration, which is only
tested under Python 3.8.

Note that the base branch is not `main`, but a branch on which we can
stage the breaking changes for the 4.0 release.

Depends on DataDog/system-tests#5547

---------

Co-authored-by: Sam Brenner <[email protected]>
Co-authored-by: Gabriele N. Tornetta <[email protected]>
This change removes the deprecated `freezegun` integration from ddtrace.

Note the base branch, a staging area for breaking changes slated for
4.0.

---------

Co-authored-by: Vlad Scherbich <[email protected]>
Co-authored-by: Taegyun Kim <[email protected]>
)

This change removes a deprecated environment variable related to
instrumentation telemetry.

Note the base branch, a staging area for breaking changes slated for
4.0.
This change removes the deprecated functionality that controls ingestion
via analytics.

Note the base branch, a staging area for breaking changes slated for
4.0.
This change replaces `ddtrace.settings` with `ddtrace.internal.settings`
because we've decided to disallow settings adjustment via code,
preferring environment variable configuration.

Note the base branch, a staging area for breaking changes slated for
4.0.
This change removes deprecated attributes from the `ddtrace.trace` and
`ddtrace._trace` modules.

Note the base branch, a staging area for breaking changes slated for
4.0.

---------

Co-authored-by: Brett Langdon <[email protected]>
## Description
[MLOB-4128]
Drops the optional tiktoken dependency from ddtrace.
Also removes tiktoken estimation of tokens from the openai integration.
This was only used by customers that explicitly rejected streamed token
metrics from streamed chat/responses, which is an extreme minority of
users. We made the call that this optional dependency wasn't worth the
maintenance burden (difficulty in updating python versions, other third
party libraries, etc) in our ddtrace 4.0 major release. We'll just
default to estimating the token count with our super simple heuristic if
token counts are not provided by openai.

This PR also updates testing to test openai==2.2.0. 

<!-- Provide an overview of the change and motivation for the change -->

## Testing

<!-- Describe your testing strategy or note what tests are included -->

## Risks

<!-- Note any risks associated with this change, or "None" if no risks
-->

## Additional Notes

<!-- Any other information that would be helpful for reviewers -->


[MLOB-4128]:
https://datadoghq.atlassian.net/browse/MLOB-4128?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
],
),
Venv(
name="profile-diff",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@P403n1x87 don't think this venv is used anywhere. Deleting.

@vlad-scherbich
Copy link
Contributor

vlad-scherbich commented Nov 11, 2025

Is there a plan to rename the remaining stack_v2 vars / files / etc to just stack? :)

@vlad-scherbich
Copy link
Contributor

I'm concerned with the size of this diff: 2.6K lines added, 6K lines removed. I think we should break this up into several PRs.

Example suggestion:
PR 1: consolidate profiling_v2 collector tests into profiling dir
PR 2: same for exporter tests
PR 3: core changes
PR 4: stack_v2 --> stack renames everywhere

@vlad-scherbich
Copy link
Contributor

vlad-scherbich commented Nov 11, 2025

One of the notable improvements from this PR is that StackCollector no longer spawns an extra background thread by inheriting from Collector instead of PeriodicService.

If this is not required for the stack v1 removal, I would make this a separate PR. Sounds like a major improvement that will benefit from extra visibility.

emmettbutler and others added 2 commits November 11, 2025 08:30
…stors (#15212)

## Description

Deprecated in 3.x, now removed in 4.0

## Testing

<!-- Describe your testing strategy or note what tests are included -->

## Risks

<!-- Note any risks associated with this change, or "None" if no risks
-->

## Additional Notes

<!-- Any other information that would be helpful for reviewers -->

Co-authored-by: Emmett Butler <[email protected]>
@taegyunkim
Copy link
Contributor Author

I'm concerned with the size of this diff: 2.6K lines added, 6K lines removed. I think we should break this up into several PRs.

Example suggestion: PR 1: consolidate profiling_v2 collector tests into profiling dir PR 2: same for exporter tests PR 3: core changes PR 4: stack_v2 --> stack renames everywhere

The removal of stack v1 is done mostly in a single PR as the deadline to make changes to 4.0-breaking-changes is today, and @brettlangdon requested me to remove the code as part of 4.0 release.

I initially thought of removing them after 4.0 was released as now it can't be enabled unless someone modifies the code to do so.

emmettbutler pushed a commit that referenced this pull request Nov 12, 2025
)

## Description

This is mainly to make sure that `DD_PROFILING_STACK_V2_ENABLED` does
nothing.

Actual code removal will be followed up in
#15185

## Testing

<!-- Describe your testing strategy or note what tests are included -->

## Risks

<!-- Note any risks associated with this change, or "None" if no risks
-->

## Additional Notes

<!-- Any other information that would be helpful for reviewers -->
@vlad-scherbich
Copy link
Contributor

Is there a plan to rename the remaining stack_v2 vars / files / etc to just stack? :)

All the *v2* comments I've made here are related to naming only. I don't know enough about the logic, yet, to suggest removing checks or changing the code flow.

So, basically, are we keeping any v2 references internally, even though there's just a single version now?

Base automatically changed from 4.0-breaking-changes to main November 12, 2025 18:52
@emmettbutler emmettbutler requested review from a team as code owners November 12, 2025 18:52
@taegyunkim
Copy link
Contributor Author

Closing in favor of #15237

@taegyunkim taegyunkim closed this Nov 13, 2025
@taegyunkim taegyunkim deleted the taegyunkim/remove-stack-v1 branch November 13, 2025 14:29
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. Profiling Continous Profling

Projects

None yet

Development

Successfully merging this pull request may close these issues.