diff --git a/cpp/src/arrow/filesystem/azurefs.cc b/cpp/src/arrow/filesystem/azurefs.cc index e47be63a4c0..7aa3e58c1d3 100644 --- a/cpp/src/arrow/filesystem/azurefs.cc +++ b/cpp/src/arrow/filesystem/azurefs.cc @@ -38,6 +38,7 @@ #include #include "arrow/buffer.h" +#include "arrow/config.h" #include "arrow/filesystem/path_util.h" #include "arrow/filesystem/util_internal.h" #include "arrow/io/util_internal.h" @@ -303,6 +304,10 @@ Status ExceptionToStatus(const Azure::Core::RequestFailedException& exception, return Status::IOError(std::forward(prefix_args)..., " Azure Error: [", exception.ErrorCode, "] ", exception.what()); } + +std::string BuildApplicationId() { + return "azpartner-arrow/" + GetBuildInfo().version_string; +} } // namespace std::string AzureOptions::AccountBlobUrl(const std::string& account_name) const { @@ -386,9 +391,12 @@ Result> AzureOptions::MakeBlobServiceC return Status::Invalid("AzureOptions::blob_storage_scheme must be http or https: ", blob_storage_scheme); } + Blobs::BlobClientOptions client_options; + client_options.Telemetry.ApplicationId = BuildApplicationId(); switch (credential_kind_) { case CredentialKind::kAnonymous: - return std::make_unique(AccountBlobUrl(account_name)); + return std::make_unique(AccountBlobUrl(account_name), + client_options); case CredentialKind::kDefault: if (!token_credential_) { token_credential_ = std::make_shared(); @@ -399,14 +407,14 @@ Result> AzureOptions::MakeBlobServiceC case CredentialKind::kCLI: case CredentialKind::kWorkloadIdentity: case CredentialKind::kEnvironment: - return std::make_unique(AccountBlobUrl(account_name), - token_credential_); + return std::make_unique( + AccountBlobUrl(account_name), token_credential_, client_options); case CredentialKind::kStorageSharedKey: - return std::make_unique(AccountBlobUrl(account_name), - storage_shared_key_credential_); + return std::make_unique( + AccountBlobUrl(account_name), storage_shared_key_credential_, client_options); case CredentialKind::kSASToken: - return std::make_unique(AccountBlobUrl(account_name) + - sas_token_); + return std::make_unique( + AccountBlobUrl(account_name) + sas_token_, client_options); } return Status::Invalid("AzureOptions doesn't contain a valid auth configuration"); } @@ -420,10 +428,12 @@ AzureOptions::MakeDataLakeServiceClient() const { return Status::Invalid("AzureOptions::dfs_storage_scheme must be http or https: ", dfs_storage_scheme); } + DataLake::DataLakeClientOptions client_options; + client_options.Telemetry.ApplicationId = BuildApplicationId(); switch (credential_kind_) { case CredentialKind::kAnonymous: return std::make_unique( - AccountDfsUrl(account_name)); + AccountDfsUrl(account_name), client_options); case CredentialKind::kDefault: if (!token_credential_) { token_credential_ = std::make_shared(); @@ -435,13 +445,13 @@ AzureOptions::MakeDataLakeServiceClient() const { case CredentialKind::kWorkloadIdentity: case CredentialKind::kEnvironment: return std::make_unique( - AccountDfsUrl(account_name), token_credential_); + AccountDfsUrl(account_name), token_credential_, client_options); case CredentialKind::kStorageSharedKey: return std::make_unique( - AccountDfsUrl(account_name), storage_shared_key_credential_); + AccountDfsUrl(account_name), storage_shared_key_credential_, client_options); case CredentialKind::kSASToken: return std::make_unique( - AccountBlobUrl(account_name) + sas_token_); + AccountBlobUrl(account_name) + sas_token_, client_options); } return Status::Invalid("AzureOptions doesn't contain a valid auth configuration"); }