Take into account sas tokens while metering put object requests on azure (#62244)

Backport of #62225
Closes #62208
This commit is contained in:
Francisco Fernández Castaño 2020-09-10 19:47:58 +02:00 committed by GitHub
parent 09b167c8dd
commit 21303e8e15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -119,11 +119,7 @@ public class AzureBlobStore implements BlobStore {
};
this.uploadMetricsCollector = (httpURLConnection -> {
assert httpURLConnection.getRequestMethod().equals("PUT");
String queryParams = httpURLConnection.getURL().getQuery();
if (queryParams == null) {
stats.putOperations.incrementAndGet();
return;
}
String queryParams = httpURLConnection.getURL().getQuery() == null ? "" : httpURLConnection.getURL().getQuery();
// https://docs.microsoft.com/en-us/rest/api/storageservices/put-block
// https://docs.microsoft.com/en-us/rest/api/storageservices/put-block-list
@ -131,6 +127,11 @@ public class AzureBlobStore implements BlobStore {
stats.putBlockOperations.incrementAndGet();
} else if (queryParams.contains("comp=blocklist")) {
stats.putBlockListOperations.incrementAndGet();
} else {
// https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#uri-parameters
// The only URI parameter allowed for put-blob operation is "timeout", but if a sas token is used,
// it's possible that the URI parameters contain additional parameters unrelated to the upload type.
stats.putOperations.incrementAndGet();
}
});
}