Skip to content

Commit

Permalink
check if response has metrics property
Browse files Browse the repository at this point in the history
  • Loading branch information
mrufsvold committed Aug 5, 2024
1 parent dc99877 commit 612810a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/blobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ API.startMultipartUpload(x::Container, key; kw...) = nothing
function API.uploadPart(x::Container, url, part, partNumber, uploadId; kw...)
blockid = base64encode(lpad(partNumber - 1, 64, '0'))
resp = Azure.put(url, [], part; query=Dict("comp" => "block", "blockid" => blockid), kw...)
return (blockid, resp.metrics.request_body_length)
body_length = if hasproperty(resp, :metrics)
resp.metrics.request_body_length
else
Base.get(resp.request.context, :nbytes_written, 0)
end
return (blockid, body_length)
end

function API.completeMultipartUpload(x::Container, url, eTags, uploadId; kw...)
Expand Down
14 changes: 12 additions & 2 deletions src/get.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,21 @@ function getObjectImpl(x::AbstractStore, key::String, out::ResponseBodyType=noth
# directly as HTTP receives the response body
_res = view(res, _rng)
r = getObject(x, url, _headers; response_stream=_res, kw...)
Threads.atomic_add!(nbytes, r.metrics.response_body_length)
body_length = if hasproperty(resp, :metrics)
resp.metrics.request_body_length
else
contentLength
end
Threads.atomic_add!(nbytes, body_length)
else
buf = view(buffers[$i], 1:min(partSize, length(rng)))
r = getObject(x, url, _headers; response_stream=buf, kw...)
Threads.atomic_add!(nbytes, r.metrics.response_body_length)
body_length = if hasproperty(resp, :metrics)
resp.metrics.request_body_length
else
contentLength
end
Threads.atomic_add!(nbytes, body_length)
put!(() -> write(body, buf), sync, _n)
end
end
Expand Down

0 comments on commit 612810a

Please sign in to comment.