-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(profiling): stack v2 tracks threads in gunicorn workers [backport…
… 2.16] (#11314) Backport 0923b51 from #11300 to 2.16. See the following screenshot for cpu profile before and after this change for a service using gunicorn. <img width="1754" alt="Screenshot 2024-11-06 at 1 55 56 PM" src="https://github.com/user-attachments/assets/e29d8b56-c789-416e-907e-4726aab33b2b"> ## 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) Co-authored-by: Taegyun Kim <taegyun.kim@datadoghq.com>
- Loading branch information
1 parent
055d352
commit c3899f7
Showing
6 changed files
with
125 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
releasenotes/notes/profiling-gunicorn-track-06a211fc1e2643e1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
fixes: | ||
- | | ||
profiling: fixes an issue where cpu-time was not profiled for services using | ||
gunicorn, when ``DD_PROFILING_STACK_V2_ENABLED` was set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
def app(): | ||
pass | ||
import os | ||
import threading | ||
|
||
|
||
def fib(n): | ||
if n <= 1: | ||
return n | ||
return fib(n - 1) + fib(n - 2) | ||
|
||
|
||
def app(environ, start_response): | ||
response_body = "fib(35) is %d at pid %d tid %d" % (fib(35), os.getpid(), threading.get_ident()) | ||
|
||
response_body = response_body.encode("utf-8") | ||
|
||
status = "200 OK" if response_body else "404 Not Found" | ||
headers = [("Content-type", "text/plain")] | ||
start_response(status, headers) | ||
return [response_body] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters