DataDog / dd-trace-py

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

fix(profiling): export lock acquire/release call location and variable name #9615

Closed taegyunkim closed 5 days ago

taegyunkim commented 1 week ago

We used to export ":" for the name of a lock. Whenever lock is initialized, we traverse the stack frame to populate these. However, we can't get the variable name of the lock as we haven't yet fully initialized and assigned it to a variable.

Now we traverse the frame whenever _acquire/_release is called to get the caller information. Also, when _acquire is called for the first time, we inspect local and global variables in the caller frame to find the name of this lock variable. With DD_PROFILING_LOCK_NAME_INSPECT_DIR enabled, the lock profiler also inspects attributes of local and global variables to find the name of the lock. This behavior can be turned off with the flag.

Checklist

Reviewer Checklist

datadog-dd-trace-py-rkomorn[bot] commented 1 week ago

Datadog Report

Branch report: taegyunkim/prof-9923-lock-names Commit report: 61bb542 Test service: dd-trace-py

:x: 9 Failed (0 Known Flaky), 750 Passed, 790 Skipped, 42m 10.62s Total duration (38m 46.27s time saved)

:x: Failed Tests (9)

This report shows up to 5 failed tests.

  • test_lock_acquire_events - test_threading_asyncio.py
pr-commenter[bot] commented 1 week ago

Benchmarks

Benchmark execution time: 2024-06-27 21:35:04

Comparing candidate commit 91f840c525dc42ad44868096c8cb216fbb741986 in PR branch taegyunkim/prof-9923-lock-names with baseline commit 303d20266ac4a07687ce05b0ecb8280f3a742517 in branch main.

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

datadog-dd-trace-py-rkomorn[bot] commented 6 days ago

Datadog Report

Branch report: taegyunkim/prof-9923-lock-names Commit report: 19cd74e Test service: dd-trace-py

:white_check_mark: 0 Failed, 812 Passed, 783 Skipped, 39m 15.07s Total duration (48m 59.42s time saved)