Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.14.1 (2024-10-31)
## 1.14.1 (2024-11-01)

### Bugs Fixed

Expand Down
1 change: 0 additions & 1 deletion sdk/core/azure-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ set(
inc/azure/core/internal/extendable_enumeration.hpp
inc/azure/core/internal/http/http_sanitizer.hpp
inc/azure/core/internal/http/pipeline.hpp
inc/azure/core/internal/http/user_agent.hpp
inc/azure/core/internal/io/null_body_stream.hpp
inc/azure/core/internal/json/json.hpp
inc/azure/core/internal/json/json_optional.hpp
Expand Down
28 changes: 28 additions & 0 deletions sdk/core/azure-core/inc/azure/core/http/http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,34 @@ namespace Azure { namespace Core { namespace Http {
}
return {}; // empty string
}

/**
* @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);

private:
HttpShared() = delete;
~HttpShared() = delete;
};
} // namespace _internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "azure/core/http/http.hpp"
#include "azure/core/http/transport.hpp"
#include "azure/core/internal/http/http_sanitizer.hpp"
#include "azure/core/internal/http/user_agent.hpp"
#include "azure/core/uuid.hpp"

#include <atomic>
Expand Down Expand Up @@ -550,7 +549,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::_internal::UserAgentGenerator::GenerateUserAgent(
: m_telemetryId(Azure::Core::Http::_internal::HttpShared::GenerateUserAgent(
packageName,
packageVersion,
options.ApplicationId,
Expand Down
44 changes: 0 additions & 44 deletions sdk/core/azure-core/inc/azure/core/internal/http/user_agent.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "azure/core/context.hpp"
#include "azure/core/internal/client_options.hpp"
#include "azure/core/internal/extendable_enumeration.hpp"
#include "azure/core/internal/http/user_agent.hpp"
#include "azure/core/internal/tracing/tracing_impl.hpp"

#pragma once
Expand Down
5 changes: 2 additions & 3 deletions sdk/core/azure-core/src/http/user_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/

#include "azure/core/context.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/http/policies/policy.hpp"
#include "azure/core/internal/strings.hpp"
#include "azure/core/internal/tracing/service_tracing.hpp"
#include "azure/core/platform.hpp"

#include <azure/core/internal/http/user_agent.hpp>

#include <sstream>

#if defined(AZ_PLATFORM_WINDOWS)
Expand Down Expand Up @@ -150,7 +149,7 @@ std::string TrimString(std::string s)

namespace Azure { namespace Core { namespace Http { namespace _internal {

std::string UserAgentGenerator::GenerateUserAgent(
std::string HttpShared::GenerateUserAgent(
std::string const& componentName,
std::string const& componentVersion,
std::string const& applicationId,
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure-core/test/ut/telemetry_policy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ TEST(TelemetryPolicy, UserAgentCppVer)
EXPECT_EQ(cppversion.str(), "TEST:201402");
}
{
const std::string ua = Http::_internal::UserAgentGenerator::GenerateUserAgent(
const std::string ua = Http::_internal::HttpShared::GenerateUserAgent(
"storage.blobs", "11.0.0-beta.1", "MyApp", 201402L);

EXPECT_GE(ua.length(), 11);
EXPECT_EQ(ua.substr(ua.length() - 11, ua.size()), "Cpp/201402)");
}

{
const std::string ua = Http::_internal::UserAgentGenerator::GenerateUserAgent(
const std::string ua = Http::_internal::HttpShared::GenerateUserAgent(
"storage.blobs", "11.0.0-beta.1", "MyApp", 201703L);

EXPECT_GE(ua.length(), 11);
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.0.0-beta.10 (2024-10-31)
## 1.0.0-beta.10 (2024-11-01)

### Bugs Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <azure/core/amqp/internal/management.hpp>
#include <azure/core/amqp/internal/session.hpp>
#include <azure/core/context.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/internal/diagnostics/log.hpp>
#include <azure/core/internal/http/user_agent.hpp>

#include <chrono>

Expand Down Expand Up @@ -277,7 +277,7 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace _detail
#endif
options.Properties.emplace(
"user-agent",
Azure::Core::Http::_internal::UserAgentGenerator::GenerateUserAgent(
Azure::Core::Http::_internal::HttpShared::GenerateUserAgent(
packageName, PackageVersion::ToString(), applicationId, cplusplusValue));
}

Expand Down