-
Notifications
You must be signed in to change notification settings - Fork 11
Initial implementation of the agent duplicated and adapted from the i… #2
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
Conversation
…nternal repository.
gimki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left some comments. I would not be bothered to have those changes in this PR. I am happy for you to push this as initial commits but I would suggest to do a clean up before we making it open source. We may possibly open source this when we release v1.0.3 onto PyPI with new features + cleanup. My comments are minor really but also something that I think we should clean up before making it visible to the community. Feel free to merge it; the comments I left are for future use really. Thanks
|
|
||
| def _maybe_append_time_sleep(result, frame, line_no): | ||
| line = linecache.getline(frame.f_code.co_filename, line_no).strip() | ||
| if "sleep(" in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we mind exposing this hardcoded hack here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behaviour is already clear for a customer with this use-case, so I don't see any reason to not include this.
| customer_handler_function = bootstrap_module._get_handler(original_handler_name) | ||
| else: | ||
| # Support for python 3.6 bootstrap which is different. It is starting to be quite hacky at this point. | ||
| # We will need to discuss if it is worth handling this case and if we can do it in a better way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rephrase comments like these(?)
Make it like a TODO or FIXME instead (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a TODO FIXME.
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I can link this back to any part of the doc on https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first link from https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-python#starting-with-the-python-workflow-template for "Python workflow template" redirects to a sample that shows this configuration. I generated the initial file by using the default wizard from GitHub.
| @@ -0,0 +1,12 @@ | |||
| class Sample: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not this PR) TODO: Make use of slot for this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, interesting.
| # [B108:hardcoded_tmp_directory] Probable insecure usage of temp file/directory. | ||
| # https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html | ||
| # This file can be used by the customer as kill switch for the Profiler. | ||
| KILLSWITCH_FILEPATH = "/var/tmp/killProfiler" #nosec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This would not work for Windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a TODO FIXME.
| import pytest | ||
|
|
||
| # Enable pytestutils @focus decoration | ||
| pytest_plugins = "test.pytestutils_focus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question: Do we need to keep this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
|
|
||
| @pytest.mark.skipif( | ||
| # TODO FIXME Remove the conditions for skipping this on Amazonian fleets when we move fully to GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to address that in cleanup commit next
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will update, thanks.
| context="expected_context") == "expected result" | ||
|
|
||
| class TestLoadModuleFunction: | ||
| class TestWhenPython38LambdaBootstrapCalls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Do we need to control that it is run for python38 only (?) I know it doesnt matter but it is a bit weird to run that for all version of python given that it said python38 explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here is more about the Python38 implementation, not necessary the version we are using. I don't see it worth it to update it considering it passes for all versions.
| self.mock_collector.add.assert_not_called() | ||
|
|
||
|
|
||
| def wait_until(predicate, max_wait_seconds=1, period_seconds=0.1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we refactored this out to utils.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll update to use the existing wait_for from help_utils, thanks.
| assert AgentConfiguration.get().sampling_interval == timedelta(milliseconds=1) | ||
| assert AgentConfiguration.get().minimum_time_reporting == timedelta(seconds=1) | ||
| assert AgentConfiguration.get().reporting_interval == timedelta(minutes=1) | ||
| assert AgentConfiguration.get().max_stack_depth == 998 No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Issue #, if available:
Description of changes:
Initial implementation of the agent duplicated and adapted from the internal repository.
Testing:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.