Add new metrics as requested by some customers
Note that the `status` field on the pull and push metrics will eventually be set to False for failed pulls and pushes in a followup PR
This commit is contained in:
parent
7fc4aa7afd
commit
4b926ae189
7 changed files with 57 additions and 21 deletions
|
@ -1,11 +1,12 @@
|
|||
import logging
|
||||
import re
|
||||
import time
|
||||
|
||||
from flask import url_for, request, redirect, Response, abort as flask_abort
|
||||
|
||||
import resumablehashlib
|
||||
|
||||
from app import storage, app, get_app_url
|
||||
from app import storage, app, get_app_url, metric_queue
|
||||
from auth.registry_jwt_auth import process_registry_jwt_auth
|
||||
from data import database
|
||||
from data.interfaces.v2 import pre_oci_model as model
|
||||
|
@ -398,6 +399,7 @@ def _upload_chunk(blob_upload, range_header):
|
|||
size_info, fn = calculate_size_handler()
|
||||
input_fp = wrap_with_handler(input_fp, fn)
|
||||
|
||||
start_time = time.time()
|
||||
length_written, new_metadata, upload_error = storage.stream_upload_chunk(
|
||||
location_set,
|
||||
blob_upload.uuid,
|
||||
|
@ -412,6 +414,10 @@ def _upload_chunk(blob_upload, range_header):
|
|||
logger.error('storage.stream_upload_chunk returned error %s', upload_error)
|
||||
return None
|
||||
|
||||
# Update the chunk upload time metric.
|
||||
metric_queue.chunk_upload_time.Observe(time.time() - start_time,
|
||||
labelvalues=[length_written, list(location_set)[0]])
|
||||
|
||||
# If we determined an uncompressed size and this is the first chunk, add it to the blob.
|
||||
# Otherwise, we clear the size from the blob as it was uploaded in multiple chunks.
|
||||
if size_info is not None and blob_upload.chunk_count == 0 and size_info.is_valid:
|
||||
|
@ -428,6 +434,7 @@ def _upload_chunk(blob_upload, range_header):
|
|||
blob_upload.storage_metadata = new_metadata
|
||||
blob_upload.byte_count += length_written
|
||||
blob_upload.chunk_count += 1
|
||||
|
||||
return blob_upload
|
||||
|
||||
|
||||
|
|
Reference in a new issue