DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
542 stars 411 forks source link

fix(profiling): capture lock usages with `with` statement context managers #9610

Closed taegyunkim closed 3 months ago

taegyunkim commented 3 months ago

Python profiler doesn't capture lock usages with with lock: statement even though this seems to be more common usage pattern.

GitHub search with /with.*lock:/ language:Python -path:test shows 228k code results GitHub search with /.*lock.acquire\(\)/ language:Python -path:test shows 89.1k code results

We'll get more lock related samples in profiles with this change.

Checklist

Reviewer Checklist

datadog-dd-trace-py-rkomorn[bot] commented 3 months ago

Datadog Report

Branch report: taegyunkim/prof-9923-lock-with Commit report: 7cb9e30 Test service: dd-trace-py

:white_check_mark: 0 Failed, 279 Passed, 771 Skipped, 34m 49.07s Total duration (42m 51.1s time saved)

pr-commenter[bot] commented 3 months ago

Benchmarks

Benchmark execution time: 2024-06-21 17:35:43

Comparing candidate commit 42c3e638df9062b546e47db3dd53e7d5cffc857b in PR branch taegyunkim/prof-9923-lock-with with baseline commit c463bb22513e797aee892c42e47c1f36cf35aa82 in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 220 metrics, 9 unstable metrics.

scenario:otelspan-start

github-actions[bot] commented 2 months ago

The backport to 2.9 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.9 2.9
# Navigate to the new working tree
cd .worktrees/backport-2.9
# Create a new branch
git switch --create backport-9610-to-2.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3cf37988ab677c1f0ad903aa9edfae42809b15fa
# Push it to GitHub
git push --set-upstream origin backport-9610-to-2.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.9

Then, create a pull request where the base branch is 2.9 and the compare/head branch is backport-9610-to-2.9.

github-actions[bot] commented 2 months ago

The backport to 2.8 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.8 2.8
# Navigate to the new working tree
cd .worktrees/backport-2.8
# Create a new branch
git switch --create backport-9610-to-2.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3cf37988ab677c1f0ad903aa9edfae42809b15fa
# Push it to GitHub
git push --set-upstream origin backport-9610-to-2.8
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.8

Then, create a pull request where the base branch is 2.8 and the compare/head branch is backport-9610-to-2.8.

github-actions[bot] commented 2 months ago

The backport to 2.7 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.7 2.7
# Navigate to the new working tree
cd .worktrees/backport-2.7
# Create a new branch
git switch --create backport-9610-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3cf37988ab677c1f0ad903aa9edfae42809b15fa
# Push it to GitHub
git push --set-upstream origin backport-9610-to-2.7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.7

Then, create a pull request where the base branch is 2.7 and the compare/head branch is backport-9610-to-2.7.