Skip to content

Commit 118d617

Browse files
committed
Add ApplicationId to AzureFileSystem for SDK calls
1 parent 1114958 commit 118d617

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

cpp/src/arrow/filesystem/azurefs.cc

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <azure/storage/files/datalake.hpp>
3939

4040
#include "arrow/buffer.h"
41+
#include "arrow/config.h"
4142
#include "arrow/filesystem/path_util.h"
4243
#include "arrow/filesystem/util_internal.h"
4344
#include "arrow/io/util_internal.h"
@@ -386,9 +387,13 @@ Result<std::unique_ptr<Blobs::BlobServiceClient>> AzureOptions::MakeBlobServiceC
386387
return Status::Invalid("AzureOptions::blob_storage_scheme must be http or https: ",
387388
blob_storage_scheme);
388389
}
390+
Blobs::BlobClientOptions client_options;
391+
client_options.Telemetry.ApplicationId =
392+
"azpartner-arrow/" + GetBuildInfo().version_string;
389393
switch (credential_kind_) {
390394
case CredentialKind::kAnonymous:
391-
return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name));
395+
return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name),
396+
client_options);
392397
case CredentialKind::kDefault:
393398
if (!token_credential_) {
394399
token_credential_ = std::make_shared<Azure::Identity::DefaultAzureCredential>();
@@ -399,14 +404,14 @@ Result<std::unique_ptr<Blobs::BlobServiceClient>> AzureOptions::MakeBlobServiceC
399404
case CredentialKind::kCLI:
400405
case CredentialKind::kWorkloadIdentity:
401406
case CredentialKind::kEnvironment:
402-
return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name),
403-
token_credential_);
407+
return std::make_unique<Blobs::BlobServiceClient>(
408+
AccountBlobUrl(account_name), token_credential_, client_options);
404409
case CredentialKind::kStorageSharedKey:
405-
return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name),
406-
storage_shared_key_credential_);
410+
return std::make_unique<Blobs::BlobServiceClient>(
411+
AccountBlobUrl(account_name), storage_shared_key_credential_, client_options);
407412
case CredentialKind::kSASToken:
408-
return std::make_unique<Blobs::BlobServiceClient>(AccountBlobUrl(account_name) +
409-
sas_token_);
413+
return std::make_unique<Blobs::BlobServiceClient>(
414+
AccountBlobUrl(account_name) + sas_token_, client_options);
410415
}
411416
return Status::Invalid("AzureOptions doesn't contain a valid auth configuration");
412417
}
@@ -420,10 +425,13 @@ AzureOptions::MakeDataLakeServiceClient() const {
420425
return Status::Invalid("AzureOptions::dfs_storage_scheme must be http or https: ",
421426
dfs_storage_scheme);
422427
}
428+
DataLake::DataLakeClientOptions client_options;
429+
client_options.Telemetry.ApplicationId =
430+
"azpartner-arrow/" + GetBuildInfo().version_string;
423431
switch (credential_kind_) {
424432
case CredentialKind::kAnonymous:
425433
return std::make_unique<DataLake::DataLakeServiceClient>(
426-
AccountDfsUrl(account_name));
434+
AccountDfsUrl(account_name), client_options);
427435
case CredentialKind::kDefault:
428436
if (!token_credential_) {
429437
token_credential_ = std::make_shared<Azure::Identity::DefaultAzureCredential>();
@@ -435,13 +443,13 @@ AzureOptions::MakeDataLakeServiceClient() const {
435443
case CredentialKind::kWorkloadIdentity:
436444
case CredentialKind::kEnvironment:
437445
return std::make_unique<DataLake::DataLakeServiceClient>(
438-
AccountDfsUrl(account_name), token_credential_);
446+
AccountDfsUrl(account_name), token_credential_, client_options);
439447
case CredentialKind::kStorageSharedKey:
440448
return std::make_unique<DataLake::DataLakeServiceClient>(
441-
AccountDfsUrl(account_name), storage_shared_key_credential_);
449+
AccountDfsUrl(account_name), storage_shared_key_credential_, client_options);
442450
case CredentialKind::kSASToken:
443451
return std::make_unique<DataLake::DataLakeServiceClient>(
444-
AccountBlobUrl(account_name) + sas_token_);
452+
AccountBlobUrl(account_name) + sas_token_, client_options);
445453
}
446454
return Status::Invalid("AzureOptions doesn't contain a valid auth configuration");
447455
}

0 commit comments

Comments
 (0)