-
Notifications
You must be signed in to change notification settings - Fork 468
chore(profiling): remove stack v1 impl #15237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6df5d6e
chore(profiling): remove stack v1 impl
taegyunkim b521da3
minimize diff
taegyunkim d4d3370
more deadcode
taegyunkim ffaf351
update test
taegyunkim f0c8e1a
update comment
taegyunkim ec1bc68
fix test
taegyunkim 676174c
Merge branch 'main' into prof-12836-v1-removal
taegyunkim 8cf0a91
update typing and ordering
taegyunkim 07a7705
Merge branch 'main' into prof-12836-v1-removal
taegyunkim 829ec7c
Merge branch 'main' into prof-12836-v1-removal
taegyunkim b8551b0
Merge branch 'main' into prof-12836-v1-removal
taegyunkim d86c3aa
Merge branch 'main' into prof-12836-v1-removal
taegyunkim 1283b2b
Apply suggestions from code review
taegyunkim 8400b0b
remove unneeded import
taegyunkim 107f3db
Merge branch 'main' into prof-12836-v1-removal
taegyunkim a0669b0
Merge branch 'main' into prof-12836-v1-removal
taegyunkim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,65 @@ | ||
| """Simple wrapper around stack_v2 native extension module.""" | ||
|
|
||
| import logging | ||
| import typing | ||
|
|
||
| from ddtrace.internal import core | ||
| from ddtrace.internal.datadog.profiling import stack_v2 | ||
| from ddtrace.internal.settings.profiling import config | ||
| from ddtrace.profiling import collector | ||
| from ddtrace.profiling.collector import threading | ||
| from ddtrace.trace import Tracer | ||
|
|
||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class StackCollector(collector.Collector): | ||
| """Execution stacks collector.""" | ||
|
|
||
| __slots__ = ( | ||
| "nframes", | ||
| "tracer", | ||
| ) | ||
|
|
||
| def __init__(self, nframes: typing.Optional[int] = None, tracer: typing.Optional[Tracer] = None): | ||
| super().__init__() | ||
|
|
||
| self.nframes = nframes if nframes is not None else config.max_frames | ||
| self.tracer = tracer | ||
|
|
||
| def __repr__(self) -> str: | ||
| class_name = self.__class__.__name__ | ||
| attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")} | ||
| attrs_str = ", ".join(f"{k}={v!r}" for k, v in attrs.items()) | ||
|
|
||
| slot_attrs = {slot: getattr(self, slot) for slot in self.__slots__ if not slot.startswith("_")} | ||
| slot_attrs_str = ", ".join(f"{k}={v!r}" for k, v in slot_attrs.items()) | ||
|
|
||
| return f"{class_name}({attrs_str}, {slot_attrs_str})" | ||
|
|
||
| def _init(self) -> None: | ||
| if self.tracer is not None: | ||
| core.on("ddtrace.context_provider.activate", stack_v2.link_span) | ||
|
|
||
| # stack v2 requires us to patch the Threading module. It's possible to do this from the stack v2 code | ||
| # itself, but it's a little bit fiddly and it's easier to make it correct here. | ||
| # TODO take the `threading` import out of here and just handle it in v2 startup | ||
| threading.init_stack_v2() | ||
| stack_v2.set_adaptive_sampling(config.stack.v2_adaptive_sampling) | ||
| stack_v2.start() | ||
|
|
||
| def _start_service(self) -> None: | ||
| # This is split in its own function to ease testing | ||
| LOG.debug("Profiling StackCollector starting") | ||
| self._init() | ||
| LOG.debug("Profiling StackCollector started") | ||
|
|
||
| def _stop_service(self) -> None: | ||
| LOG.debug("Profiling StackCollector stopping") | ||
| if self.tracer is not None: | ||
| core.reset_listeners("ddtrace.context_provider.activate", stack_v2.link_span) | ||
| LOG.debug("Profiling StackCollector stopped") | ||
|
|
||
| # Tell the native thread running the v2 sampler to stop | ||
| stack_v2.stop() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.