diff --git a/cmake-modules/AzureGlobalCompileOptions.cmake b/cmake-modules/AzureGlobalCompileOptions.cmake index 6a771a6ce..73a81cf3a 100644 --- a/cmake-modules/AzureGlobalCompileOptions.cmake +++ b/cmake-modules/AzureGlobalCompileOptions.cmake @@ -15,6 +15,9 @@ if(MSVC) #https://stackoverflow.com/questions/37527946/warning-unreferenced-inline-function-has-been-removed add_compile_options(/permissive- /W4 ${WARNINGS_AS_ERRORS_FLAG} /wd5031 /wd4668 /wd4820 /wd4255 /wd4710) + #https://learn.microsoft.com/cpp/build/reference/zc-cplusplus?view=msvc-170 + add_compile_options(/Zc:__cplusplus) + # NOTE: Static analysis will slow building time considerably and it is run during CI gates. # It is better to turn in on to debug errors reported by CI than have it ON all the time. if (DEFINED ENV{AZURE_ENABLE_STATIC_ANALYSIS}) diff --git a/cmake-modules/FolderList.cmake b/cmake-modules/FolderList.cmake index db7b4b2e9..770f97a15 100644 --- a/cmake-modules/FolderList.cmake +++ b/cmake-modules/FolderList.cmake @@ -33,7 +33,7 @@ macro(GetFolderList project) elseif(${project} STREQUAL DATA_TABLES) DownloadDepVersion(sdk/core azure-core 1.11.3) elseif(${project} STREQUAL EVENTHUBS) - DownloadDepVersion(sdk/core azure-core 1.11.3) + DownloadDepVersion(sdk/core azure-core 1.14.1) DownloadDepVersion(sdk/core azure-core-amqp 1.0.0-beta.9) elseif(${project} STREQUAL EVENTHUBS_CHECKPOINTSTORE_BLOB) DownloadDepVersion(sdk/core azure-core 1.10.1) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index b5ad2c8c1..5072d301e 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -1,10 +1,6 @@ # Release History -## 1.15.0-beta.1 (Unreleased) - -### Features Added - -### Breaking Changes +## 1.14.1 (2024-10-31) ### Bugs Fixed @@ -14,6 +10,7 @@ ### Other Changes - [[#6087]](https://github.com/Azure/azure-sdk-for-cpp/pull/6087) Set version property for the compiled SDK binary files. (A community contribution, courtesy of _[chewi](https://github.com/chewi)_) +- [[#6064]](https://github.com/Azure/azure-sdk-for-cpp/issues/6064) Added internal support for the SDK packages to access more of telemetry features. ### Acknowledgments diff --git a/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp b/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp index c7b54b1bb..513871b90 100644 --- a/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp @@ -88,8 +88,13 @@ namespace Azure { namespace Core { namespace Http { namespace Policies { -1L #elif defined(_azure_BUILDING_SAMPLES) 0L +#else + // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#if defined(_MSVC_LANG) && __cplusplus == 199711L + _MSVC_LANG #else __cplusplus +#endif #endif ; }; @@ -545,7 +550,7 @@ namespace Azure { namespace Core { namespace Http { namespace Policies { std::string const& packageName, std::string const& packageVersion, TelemetryOptions options = TelemetryOptions()) - : m_telemetryId(Azure::Core::Http::_detail::UserAgentGenerator::GenerateUserAgent( + : m_telemetryId(Azure::Core::Http::_internal::UserAgentGenerator::GenerateUserAgent( packageName, packageVersion, options.ApplicationId, diff --git a/sdk/core/azure-core/inc/azure/core/internal/http/user_agent.hpp b/sdk/core/azure-core/inc/azure/core/internal/http/user_agent.hpp index 43feca858..3d5a0ad73 100644 --- a/sdk/core/azure-core/inc/azure/core/internal/http/user_agent.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/http/user_agent.hpp @@ -10,26 +10,35 @@ #include -namespace Azure { namespace Core { namespace Http { namespace _detail { - // NOTE: Treat Azure::Core::Http::_detail::UserAgentGenerator::GenerateUserAgent() as _internal - - // it is being/has been used by eventhubs. +namespace Azure { namespace Core { namespace Http { namespace _internal { + /** + * @brief Telemetry User-Agent string generator. + * + */ class UserAgentGenerator { public: + /** + * @brief Generates User-Agent string for telemetry. + * + * @param componentName the name of the SDK component. + * @param componentVersion the version of the SDK component. + * @param applicationId user application ID + * @param cplusplusValue value of the `__cplusplus` macro. + * + * @return User-Agent string. + * + * @see https://azure.github.io/azure-sdk/general_azurecore.html#telemetry-policy + * + * @note Values for @a cplusplusValue: `__cplusplus` when value comes from the code being built + * after the Azure SDK has been built. `0L` when being sent from sample code, `-1L` when being + * sent from tests code, `-2L` when being sent from the SDK code, and `-3L` when being sent from + * the SDK code for compatibility reasons. + * + */ static std::string GenerateUserAgent( std::string const& componentName, std::string const& componentVersion, std::string const& applicationId, long cplusplusValue); - - [[deprecated("Use an overload with additional cplusplusValue parameter.")]] static std::string - GenerateUserAgent( - std::string const& componentName, - std::string const& componentVersion, - std::string const& applicationId) - { - // The value of -3L is to signify that an old version of signature has been used (older - // version of eventhubs); we can't rely on cpp version reported by it. - return GenerateUserAgent(componentName, componentVersion, applicationId, -3L); - } }; -}}}} // namespace Azure::Core::Http::_detail +}}}} // namespace Azure::Core::Http::_internal diff --git a/sdk/core/azure-core/src/http/user_agent.cpp b/sdk/core/azure-core/src/http/user_agent.cpp index 4f3ff7f91..ae2bcd58e 100644 --- a/sdk/core/azure-core/src/http/user_agent.cpp +++ b/sdk/core/azure-core/src/http/user_agent.cpp @@ -148,7 +148,7 @@ std::string TrimString(std::string s) } } // namespace -namespace Azure { namespace Core { namespace Http { namespace _detail { +namespace Azure { namespace Core { namespace Http { namespace _internal { std::string UserAgentGenerator::GenerateUserAgent( std::string const& componentName, @@ -170,4 +170,4 @@ namespace Azure { namespace Core { namespace Http { namespace _detail { return telemetryId.str(); } -}}}} // namespace Azure::Core::Http::_detail +}}}} // namespace Azure::Core::Http::_internal diff --git a/sdk/core/azure-core/src/private/package_version.hpp b/sdk/core/azure-core/src/private/package_version.hpp index d7e196335..d82ca7e65 100644 --- a/sdk/core/azure-core/src/private/package_version.hpp +++ b/sdk/core/azure-core/src/private/package_version.hpp @@ -11,9 +11,9 @@ #include #define AZURE_CORE_VERSION_MAJOR 1 -#define AZURE_CORE_VERSION_MINOR 15 -#define AZURE_CORE_VERSION_PATCH 0 -#define AZURE_CORE_VERSION_PRERELEASE "beta.1" +#define AZURE_CORE_VERSION_MINOR 14 +#define AZURE_CORE_VERSION_PATCH 1 +#define AZURE_CORE_VERSION_PRERELEASE "" #define AZURE_CORE_VERSION_ITOA_HELPER(i) #i #define AZURE_CORE_VERSION_ITOA(i) AZURE_CORE_VERSION_ITOA_HELPER(i) diff --git a/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp b/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp index f6c9c709c..d931d6e26 100644 --- a/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp +++ b/sdk/core/azure-core/test/ut/telemetry_policy_test.cpp @@ -95,7 +95,12 @@ TEST(TelemetryPolicy, telemetryString) TEST(TelemetryPolicy, UserAgentCppVer) { { - const std::string ua = Http::_detail::UserAgentGenerator::GenerateUserAgent( + std::ostringstream cppversion; + cppversion << "TEST:" << __cplusplus; + EXPECT_EQ(cppversion.str(), "TEST:201402"); + } + { + const std::string ua = Http::_internal::UserAgentGenerator::GenerateUserAgent( "storage.blobs", "11.0.0-beta.1", "MyApp", 201402L); EXPECT_GE(ua.length(), 11); @@ -103,7 +108,7 @@ TEST(TelemetryPolicy, UserAgentCppVer) } { - const std::string ua = Http::_detail::UserAgentGenerator::GenerateUserAgent( + const std::string ua = Http::_internal::UserAgentGenerator::GenerateUserAgent( "storage.blobs", "11.0.0-beta.1", "MyApp", 201703L); EXPECT_GE(ua.length(), 11); diff --git a/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md b/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md index 7c8b9b31c..a918a006e 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md +++ b/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.0.0-beta.10 (Unreleased) - -### Features Added - -### Breaking Changes +## 1.0.0-beta.10 (2024-10-31) ### Bugs Fixed -### Other Changes +- [[#6064]](https://github.com/Azure/azure-sdk-for-cpp/issues/6064) Utilize new telemetry features from Azure Core. ## 1.0.0-beta.9 (2024-06-11) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/consumer_client.hpp b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/consumer_client.hpp index a610e5df5..80b5e9208 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/consumer_client.hpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/consumer_client.hpp @@ -55,8 +55,13 @@ namespace Azure { namespace Messaging { namespace EventHubs { -1L #elif defined(_azure_BUILDING_SAMPLES) 0L +#else + // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#if defined(_MSVC_LANG) && __cplusplus == 199711L + _MSVC_LANG #else __cplusplus +#endif #endif ; }; diff --git a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/producer_client.hpp b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/producer_client.hpp index 7db305369..2485c6ec5 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/producer_client.hpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/inc/azure/messaging/eventhubs/producer_client.hpp @@ -57,8 +57,13 @@ namespace Azure { namespace Messaging { namespace EventHubs { -1L #elif defined(_azure_BUILDING_SAMPLES) 0L +#else + // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#if defined(_MSVC_LANG) && __cplusplus == 199711L + _MSVC_LANG #else __cplusplus +#endif #endif ; }; diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/private/eventhubs_utilities.hpp b/sdk/eventhubs/azure-messaging-eventhubs/src/private/eventhubs_utilities.hpp index d2989000f..111538cfb 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/private/eventhubs_utilities.hpp +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/private/eventhubs_utilities.hpp @@ -277,7 +277,7 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace _detail #endif options.Properties.emplace( "user-agent", - Azure::Core::Http::_detail::UserAgentGenerator::GenerateUserAgent( + Azure::Core::Http::_internal::UserAgentGenerator::GenerateUserAgent( packageName, PackageVersion::ToString(), applicationId, cplusplusValue)); } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/vcpkg/vcpkg.json b/sdk/eventhubs/azure-messaging-eventhubs/vcpkg/vcpkg.json index d6b600b1d..5545dd395 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/vcpkg/vcpkg.json +++ b/sdk/eventhubs/azure-messaging-eventhubs/vcpkg/vcpkg.json @@ -15,6 +15,11 @@ "homepage": "https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/eventhubs/azure-messaging-eventhubs", "license": "MIT", "dependencies": [ + { + "name": "azure-core-cpp", + "default-features": false, + "version>=": "1.14.1" + }, { "name": "azure-core-amqp-cpp", "default-features": false,