Skip to content

Commit

Permalink
Logs: always log documentation size in megabytes (#10812)
Browse files Browse the repository at this point in the history
* Logs: always log documentation size in megabytes

This allows us to have a numeric value in the output and be able to filter it
using `>` and `<` symbols on New Relic queries.

* Parse it as int

Co-authored-by: Santos Gallegos <stsewd@proton.me>

---------

Co-authored-by: Santos Gallegos <stsewd@proton.me>
  • Loading branch information
humitos and stsewd authored Oct 10, 2023
1 parent 685a255 commit d9fa3cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions readthedocs/projects/tasks/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,14 +964,14 @@ def store_build_artifacts(self):
def _log_directory_size(self, directory, media_type):
try:
output = subprocess.check_output(
["du", "--summarize", "--human-readable", "--", directory]
["du", "--summarize", "-m", "--", directory]
)
# The output is something like: "1.2M\t/path/to/directory".
directory_size = output.decode().split()[0]
# The output is something like: "5\t/path/to/directory".
directory_size = int(output.decode().split()[0])
log.info(
"Build artifacts directory size.",
directory=directory,
size=directory_size,
size=directory_size, # Size in mega bytes
media_type=media_type,
)
except Exception:
Expand Down

0 comments on commit d9fa3cf

Please sign in to comment.