-
Notifications
You must be signed in to change notification settings - Fork 3
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
Sarc 319 log trace diskusage #107
Draft
nurbal
wants to merge
8
commits into
master
Choose a base branch
from
SARC-319-log-trace-diskusage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
09a6263
add test of logs and traces in test_nila_diskusage
nurbal 7bd0466
add logs and trace in acquire diskusage
nurbal c58821f
add using_span context manager to handle traces and limit exceptions …
nurbal 8d02b0e
lint
nurbal 659960f
ADD 3 unit tests for using_traces
nurbal a072636
Merge commit '26b95a2e79594aa462e4bbd184f6ab8e038b180a' into SARC-319…
nurbal ad12ce8
Merge branch 'master' into SARC-319-log-trace-diskusage
nurbal 7584aaa
Merge branch 'master' into SARC-319-log-trace-diskusage
nurbal 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 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,3 +1,4 @@ | ||
import logging | ||
from dataclasses import dataclass | ||
|
||
from simple_parsing import field | ||
|
@@ -6,6 +7,7 @@ | |
from sarc.storage.diskusage import get_diskusage_collection | ||
from sarc.storage.drac import fetch_diskusage_report as fetch_dirac_diskusage | ||
from sarc.storage.mila import fetch_diskusage_report as fetch_mila_diskusage | ||
from sarc.traces import using_trace | ||
|
||
methods = { | ||
"default": fetch_dirac_diskusage, | ||
|
@@ -22,18 +24,23 @@ def execute(self) -> int: | |
cfg = config() | ||
|
||
for cluster_name in self.cluster_names: | ||
print(f"Acquiring {cluster_name} storages report...") | ||
with using_trace("AcquireStorages", "cluster") as span: | ||
span.set_attribute("cluster_name", cluster_name) | ||
|
||
cluster = cfg.clusters[cluster_name] | ||
# pylint: disable=logging-fstring-interpolation | ||
logging.info(f"Acquiring {cluster_name} storages report...") | ||
span.add_event(f"Acquiring {cluster_name} storages report...") | ||
|
||
fetch_diskusage = methods.get(cluster_name, methods["default"]) | ||
du = fetch_diskusage(cluster) | ||
cluster = cfg.clusters[cluster_name] | ||
|
||
if not self.dry: | ||
collection = get_diskusage_collection() | ||
collection.add(du) | ||
else: | ||
print("Document:") | ||
print(du.json(indent=2)) | ||
fetch_diskusage = methods.get(cluster_name, methods["default"]) | ||
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. Il y aurait certainement des parties à instrumenter dans les implémentations de |
||
du = fetch_diskusage(cluster) | ||
|
||
if not self.dry: | ||
collection = get_diskusage_collection() | ||
collection.add(du) | ||
else: | ||
print("Document:") | ||
print(du.json(indent=2)) | ||
|
||
return 0 |
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
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.
Faudrait qu'on décide si on veut les arguments séparé pour pouvoir envoyer en json. Sinon faudrait mettre l'exception pylint dans la config.