-
Notifications
You must be signed in to change notification settings - Fork 614
Swarming: Tag metrics with swarming runtime. #5248
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
10 commits
Select commit
Hold shift + click to select a range
11f84d3
Improve logging for swarming bots
IvanBM18 d811e01
Make is_running_on_swarming public and fix linter issues
IvanBM18 aeceb80
Removes circular dependency in logs.py & Adresses comments
IvanBM18 a47f3bf
Metrics now register swarming fuzzing hours & adds unit tests
IvanBM18 f7bfe20
Merge branch 'master' into feature/swarming/improve_metrics
IvanBM18 7e87ce5
Refines conditional and removes repetead code
IvanBM18 5e83623
Fix Failing Unit Tests
IvanBM18 88e02ad
Merge branch 'master' into feature/swarming/improve_metrics
jardondiego 5bfbde1
Cleans UT so env vars dont look misleading
IvanBM18 e41ede7
Tags error count for swarming
IvanBM18 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,17 +54,13 @@ | |
| _default_extras = {} | ||
|
|
||
|
|
||
| def _is_running_on_k8s(): | ||
| """Returns whether or not we're running on K8s.""" | ||
| # We do this here to avoid circular imports with environment. | ||
| return os.getenv('IS_K8S_ENV') == 'true' | ||
|
|
||
|
|
||
| def _increment_error_count(): | ||
| """"Increment the error count metric.""" | ||
| if _is_running_on_k8s(): | ||
| if environment.is_running_on_swarming(): | ||
| task_name = 'swarming' | ||
| elif environment.is_running_on_k8s(): | ||
| task_name = 'k8s' | ||
| elif _is_running_on_app_engine(): | ||
| elif environment.is_running_on_app_engine(): | ||
| task_name = 'appengine' | ||
| else: | ||
| task_name = os.getenv('TASK_NAME', 'unknown') | ||
|
|
@@ -79,15 +75,6 @@ def _is_local(): | |
| os.getenv('SERVER_SOFTWARE', '').startswith('Development/')) | ||
|
|
||
|
|
||
| def _is_running_on_app_engine(): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: |
||
| """Return whether or not we're running on App Engine (production or | ||
| development).""" | ||
| return os.getenv('GAE_ENV') or ( | ||
| os.getenv('SERVER_SOFTWARE') and | ||
| (os.getenv('SERVER_SOFTWARE').startswith('Development/') or | ||
| os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/'))) | ||
|
|
||
|
|
||
| def _console_logging_enabled(): | ||
| """Return bool on where console logging is enabled, usually for tests.""" | ||
| return bool(os.getenv('LOG_TO_CONSOLE')) | ||
|
|
@@ -558,7 +545,6 @@ def configure_swarming(name: str, extras: dict[str, str] | None = None) -> None: | |
| global _default_extras | ||
| _default_extras = extras | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
|
IvanBM18 marked this conversation as resolved.
|
||
| if _cloud_logging_enabled(): | ||
| configure_cloud_logging() | ||
|
|
||
|
|
@@ -579,11 +565,11 @@ def configure(name, extras=None): | |
| configure_swarming(name, extras) | ||
| return | ||
|
|
||
| if _is_running_on_k8s(): | ||
| if environment.is_running_on_k8s(): | ||
| configure_k8s() | ||
| return | ||
|
|
||
| if _is_running_on_app_engine(): | ||
| if environment.is_running_on_app_engine(): | ||
| configure_appengine() | ||
| return | ||
|
|
||
|
|
@@ -613,7 +599,7 @@ def get_logger(): | |
| if _logger: | ||
| return _logger | ||
|
|
||
| if _is_running_on_app_engine() or _is_running_on_k8s(): | ||
| if environment.is_running_on_app_engine() or environment.is_running_on_k8s(): | ||
| # Running on App Engine. | ||
| set_logger(logging.getLogger()) | ||
|
|
||
|
|
@@ -645,7 +631,7 @@ def get_source_location(): | |
|
|
||
| def _add_appengine_trace(extras): | ||
| """Add App Engine tracing information.""" | ||
| if not _is_running_on_app_engine(): | ||
| if not environment.is_running_on_app_engine(): | ||
| return | ||
|
|
||
| from libs import auth | ||
|
|
@@ -724,7 +710,7 @@ def emit(level, message, exc_info=None, **extras): | |
|
|
||
| path_name, line_number, method_name = get_source_location() | ||
|
|
||
| if _is_running_on_app_engine(): | ||
| if environment.is_running_on_app_engine(): | ||
| if exc_info == (None, None, None): | ||
| # Don't pass exc_info at all, as otherwise cloud logging will append | ||
| # "NoneType: None" to the message. | ||
|
|
||
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
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.
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.
Now that we dont have a circular dependency we can start using the same method that its declared on
environment.py