commit d03a3e08ccd8da59751a2621930261ba2a2d397b parent 9a77697f1bec6f78417b007192b38eef7923e9b0 Author: Michael van Straten <mvanstraten@mozilla.com> Date: Sat, 18 Oct 2025 16:37:57 +0000 Bug 1990985 - Update opentelemetry-cpp to v1.23.0 r=jari Differential Revision: https://phabricator.services.mozilla.com/D266303 Diffstat:
23 files changed, 600 insertions(+), 131 deletions(-)
diff --git a/third_party/opentelemetry-cpp/CHANGELOG.md b/third_party/opentelemetry-cpp/CHANGELOG.md @@ -15,6 +15,230 @@ Increment the: ## [Unreleased] +## [1.23 2025-09-25] + +* [CodeHealth] Fix clang-tidy warnings part 6 + [#3507](https://github.com/open-telemetry/opentelemetry-cpp/pull/3507) + +* [CMAKE] Add CMake scripts to find or fetch curl and find zlib + [#3526](https://github.com/open-telemetry/opentelemetry-cpp/pull/3526) + +* [REMOVAL] remove unused ci bash scripts + [#3541](https://github.com/open-telemetry/opentelemetry-cpp/pull/3541) + +* Bump step-security/harden-runner from 2.12.2 to 2.13.0 + [#3542](https://github.com/open-telemetry/opentelemetry-cpp/pull/3542) + +* [SDK] Ensure TraceId is portable on big-endian architectures + [#3543](https://github.com/open-telemetry/opentelemetry-cpp/pull/3543) + +* [TEST] Shared otel-cpp libs linked to latest static protobuf and grpc + [#3544](https://github.com/open-telemetry/opentelemetry-cpp/pull/3544) + +* [CONFIGURATION] File configuration - component registry + [#3537](https://github.com/open-telemetry/opentelemetry-cpp/pull/3537) + +* [SDK] Implement env var configuration for PeriodicExportingMetricReader + [#3549](https://github.com/open-telemetry/opentelemetry-cpp/pull/3549) + +* [SDK] Update default exemplar reservoir size for exponential histograms + [#3551](https://github.com/open-telemetry/opentelemetry-cpp/pull/3551) + +* [SDK] Implements options for the ParentBasedSampler with default values + [#3553](https://github.com/open-telemetry/opentelemetry-cpp/pull/3553) + +* Bump github/codeql-action from 3.29.2 to 3.29.3 + [#3556](https://github.com/open-telemetry/opentelemetry-cpp/pull/3556) + +* [CMAKE] Add CMake scripts to find or fetch protobuf and grpc + [#3533](https://github.com/open-telemetry/opentelemetry-cpp/pull/3533) + +* [CONFIGURATION] File configuration - sdk builder + [#3550](https://github.com/open-telemetry/opentelemetry-cpp/pull/3550) + +* Bump github/codeql-action from 3.29.3 to 3.29.4 + [#3558](https://github.com/open-telemetry/opentelemetry-cpp/pull/3558) + +* [CONFIGURATION] File configuration - spec version 1.0.0-rc1 + [#3557](https://github.com/open-telemetry/opentelemetry-cpp/pull/3557) + +* [CONFIGURATION] File configuration - sdk resource + [#3567](https://github.com/open-telemetry/opentelemetry-cpp/pull/3567) + +* [CONFIGURATION] File configuration - ostream exporter builders + [#3563](https://github.com/open-telemetry/opentelemetry-cpp/pull/3563) + +* [CONFIGURATION] File configuration - prometheus exporter builder + [#3564](https://github.com/open-telemetry/opentelemetry-cpp/pull/3564) + +* [CONFIGURATION] File configuration - zipkin exporter builder + [#3565](https://github.com/open-telemetry/opentelemetry-cpp/pull/3565) + +* [CONFIGURATION] File configuration - otlp exporter builders + [#3566](https://github.com/open-telemetry/opentelemetry-cpp/pull/3566) + +* [CMAKE] Don't set iwyu and clang-tidy properties on nlohmann_json with cmake <3.19 + [#3568](https://github.com/open-telemetry/opentelemetry-cpp/pull/3568) + +* [SDK] View should not have a unit + [#3552](https://github.com/open-telemetry/opentelemetry-cpp/pull/3552) + +* [EXPORTER] Fixes tsan warnings + [#3531](https://github.com/open-telemetry/opentelemetry-cpp/pull/3531) + +* [DOC] Document minimum required versions + [#3562](https://github.com/open-telemetry/opentelemetry-cpp/pull/3562) + +* Bump github/codeql-action from 3.29.4 to 3.29.5 + [#3574](https://github.com/open-telemetry/opentelemetry-cpp/pull/3574) + +* Add subscript to issue templates + [#3576](https://github.com/open-telemetry/opentelemetry-cpp/pull/3576) + +* [CONFIGURATION] File configuration - configuration example + [#3573](https://github.com/open-telemetry/opentelemetry-cpp/pull/3573) + +* Bump actions/download-artifact from 4.3.0 to 5.0.0 + [#3578](https://github.com/open-telemetry/opentelemetry-cpp/pull/3578) + +* Bump actions/cache from 4.2.3 to 4.2.4 + [#3580](https://github.com/open-telemetry/opentelemetry-cpp/pull/3580) + +* [SDK] Implementation of container resource as per semconv + [#3572](https://github.com/open-telemetry/opentelemetry-cpp/pull/3572) + +* Bump github/codeql-action from 3.29.7 to 3.29.8 + [#3584](https://github.com/open-telemetry/opentelemetry-cpp/pull/3584) + +* [CI] update do_ci scripts to use common cmake cache scripts + [#3582](https://github.com/open-telemetry/opentelemetry-cpp/pull/3582) + +* Bump actions/checkout from 4.2.2 to 5.0.0 + [#3587](https://github.com/open-telemetry/opentelemetry-cpp/pull/3587) + +* Bump github/codeql-action from 3.29.8 to 3.29.9 + [#3589](https://github.com/open-telemetry/opentelemetry-cpp/pull/3589) + +* [BUILD] Remove duplicated deprecated warnings in logs headers + [#3592](https://github.com/open-telemetry/opentelemetry-cpp/pull/3592) + +* Bump github/codeql-action from 3.29.9 to 3.29.10 + [#3595](https://github.com/open-telemetry/opentelemetry-cpp/pull/3595) + +* [resource_detectors] implementation of process resource detector as per semconv + [#3591](https://github.com/open-telemetry/opentelemetry-cpp/pull/3591) + +* Bump codecov/codecov-action from 5.4.3 to 5.5.0 + [#3597](https://github.com/open-telemetry/opentelemetry-cpp/pull/3597) + +* Bump github/codeql-action from 3.29.10 to 3.29.11 + [#3602](https://github.com/open-telemetry/opentelemetry-cpp/pull/3602) + +* [BAZEL] Drop rules_foreign_cc as a dependency + [#3601](https://github.com/open-telemetry/opentelemetry-cpp/pull/3601) + +* [BUILD] Remove cmake support for thrift as Jaeger was removed + [#3604](https://github.com/open-telemetry/opentelemetry-cpp/pull/3604) + +* [CMAKE] upgrade cmake minimum version to 3.16 + [#3599](https://github.com/open-telemetry/opentelemetry-cpp/pull/3599) + +* [CMAKE] Set the project version through the cmake project macro + [#3605](https://github.com/open-telemetry/opentelemetry-cpp/pull/3605) + +* [CONFIGURATION] File configuration - functional tests + [#3606](https://github.com/open-telemetry/opentelemetry-cpp/pull/3606) + +* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.37.0 + [#3615](https://github.com/open-telemetry/opentelemetry-cpp/pull/3615) + +* [BUILD] Use -dev versions in main branch + [#3609](https://github.com/open-telemetry/opentelemetry-cpp/pull/3609) + +* [BAZEL] Fix version warnings in MODULE.bazel + [#3617](https://github.com/open-telemetry/opentelemetry-cpp/pull/3617) + +* [Copilot] Add instructions for OpenTelemetry C++ + [#3614](https://github.com/open-telemetry/opentelemetry-cpp/pull/3614) + +* [MAINTAINER] Maintain version numbers with tbump + [#3616](https://github.com/open-telemetry/opentelemetry-cpp/pull/3616) + +* Bump github/codeql-action from 3.29.11 to 3.30.0 + [#3621](https://github.com/open-telemetry/opentelemetry-cpp/pull/3621) + +* Bump benchmark-action/github-action-benchmark from 1.20.4 to 1.20.5 + [#3623](https://github.com/open-telemetry/opentelemetry-cpp/pull/3623) + +* [BUILD] Cleanup cppcheck warnings + [#3619](https://github.com/open-telemetry/opentelemetry-cpp/pull/3619) + +* Bump actions/stale from 9.1.0 to 10.0.0 + [#3626](https://github.com/open-telemetry/opentelemetry-cpp/pull/3626) + +* Bump actions/github-script from 7.0.1 to 8.0.0 + [#3627](https://github.com/open-telemetry/opentelemetry-cpp/pull/3627) + +* Bump codecov/codecov-action from 5.5.0 to 5.5.1 + [#3625](https://github.com/open-telemetry/opentelemetry-cpp/pull/3625) + +* [resource_detectors] implementation of remaining process attributes + [#3603](https://github.com/open-telemetry/opentelemetry-cpp/pull/3603) + +* Bump benchmark-action/github-action-benchmark from 1.20.5 to 1.20.7 + [#3631](https://github.com/open-telemetry/opentelemetry-cpp/pull/3631) + +* Bump github/codeql-action from 3.30.0 to 3.30.1 + [#3630](https://github.com/open-telemetry/opentelemetry-cpp/pull/3630) + +* Bump github/codeql-action from 3.30.1 to 3.30.2 + [#3637](https://github.com/open-telemetry/opentelemetry-cpp/pull/3637) + +* Bump step-security/harden-runner from 2.13.0 to 2.13.1 + [#3636](https://github.com/open-telemetry/opentelemetry-cpp/pull/3636) + +* Bump github/codeql-action from 3.30.2 to 3.30.3 + [#3639](https://github.com/open-telemetry/opentelemetry-cpp/pull/3639) + +* [Metrics] New Attribute Processor for Exclude list + [#3633](https://github.com/open-telemetry/opentelemetry-cpp/pull/3633) + +* Implementing configurable aggregation cardinality limit + [#3624](https://github.com/open-telemetry/opentelemetry-cpp/pull/3624) + +* [CMAKE] Fix CMake 4.x build error on MacOS runner and when building opentracing + [#3649](https://github.com/open-telemetry/opentelemetry-cpp/pull/3649) + +* [SDK] custom hash and equality for attribute processor + [#3643](https://github.com/open-telemetry/opentelemetry-cpp/pull/3643) + +* Bump actions/cache from 4.2.4 to 4.3.0 + [#3658](https://github.com/open-telemetry/opentelemetry-cpp/pull/3658) + +* [SDK] Fix copying overflow attributes in metric AttributesHashMap + [#3651](https://github.com/open-telemetry/opentelemetry-cpp/pull/3651) + +Important changes: + +* [CMAKE] Upgrade CMake minimum version to 3.16 + [#3599](https://github.com/open-telemetry/opentelemetry-cpp/pull/3599) + +* [BUILD] Use -dev versions in main branch + [#3609](https://github.com/open-telemetry/opentelemetry-cpp/pull/3609) + * The version number in the main branch has changed, + to better differentiate with the latest release. + * For example: + * With a latest release 1.22.0, the main branch is 1.23.0-dev + * Upon release of 1.23.0, the main branch becomes 1.24.0-dev + +Breaking changes: + +* [SDK] View should not have a unit + [#3552](https://github.com/open-telemetry/opentelemetry-cpp/pull/3552) + * The `unit` parameter has been removed from the `View` constructor + and `ViewFactory::Create` methods. + * Please adjust SDK configuration code accordingly. + ## [1.22 2025-07-11] * [DOC] Udpate link to membership document @@ -1404,7 +1628,7 @@ Important changes: * [ETW EXPORTER] Remove namespace using in ETW exporter which affects global namespace [#2531](https://github.com/open-telemetry/opentelemetry-cpp/pull/2531) -* [BUILD] Don't invoke vcpkg from this repo with CMAKE_TOOLCHAIN_FILE set +* [BUILD] Don't invoke vcpkg from this repo with CMAKE_TOOLCHAIN_FILE set [#2527](https://github.com/open-telemetry/opentelemetry-cpp/pull/2527) * [EXPORTER] Async exporting for otlp grpc [#2407](https://github.com/open-telemetry/opentelemetry-cpp/pull/2407) diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h @@ -3,6 +3,8 @@ #pragma once +#include <ctype.h> + #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/context/context_value.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/context/context_value.h @@ -10,6 +10,11 @@ #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE +namespace baggage +{ +class Baggage; +} // namespace baggage + namespace trace { class Span; @@ -24,6 +29,7 @@ using ContextValue = nostd::variant<nostd::monostate, uint64_t, double, nostd::shared_ptr<trace::Span>, - nostd::shared_ptr<trace::SpanContext>>; + nostd::shared_ptr<trace::SpanContext>, + nostd::shared_ptr<baggage::Baggage>>; } // namespace context OPENTELEMETRY_END_NAMESPACE diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -247,47 +247,29 @@ static constexpr const char *kProcessWorkingDirectory = "process.working_directo namespace ProcessContextSwitchTypeValues { -/** - none - */ + static constexpr const char *kVoluntary = "voluntary"; -/** - none - */ static constexpr const char *kInvoluntary = "involuntary"; } // namespace ProcessContextSwitchTypeValues namespace ProcessCpuStateValues { -/** - none - */ + static constexpr const char *kSystem = "system"; -/** - none - */ static constexpr const char *kUser = "user"; -/** - none - */ static constexpr const char *kWait = "wait"; } // namespace ProcessCpuStateValues namespace ProcessPagingFaultTypeValues { -/** - none - */ + static constexpr const char *kMajor = "major"; -/** - none - */ static constexpr const char *kMinor = "minor"; } // namespace ProcessPagingFaultTypeValues diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h @@ -44,64 +44,29 @@ static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; namespace TelemetrySdkLanguageValues { -/** - none - */ + static constexpr const char *kCpp = "cpp"; -/** - none - */ static constexpr const char *kDotnet = "dotnet"; -/** - none - */ static constexpr const char *kErlang = "erlang"; -/** - none - */ static constexpr const char *kGo = "go"; -/** - none - */ static constexpr const char *kJava = "java"; -/** - none - */ static constexpr const char *kNodejs = "nodejs"; -/** - none - */ static constexpr const char *kPhp = "php"; -/** - none - */ static constexpr const char *kPython = "python"; -/** - none - */ static constexpr const char *kRuby = "ruby"; -/** - none - */ static constexpr const char *kRust = "rust"; -/** - none - */ static constexpr const char *kSwift = "swift"; -/** - none - */ static constexpr const char *kWebjs = "webjs"; } // namespace TelemetrySdkLanguageValues diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/std/variant.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/std/variant.h @@ -220,13 +220,9 @@ inline constexpr bool holds_alternative(const variant<Ts...> &v) noexcept return v.index() == I; } -template <typename T, template<typename...> typename U, typename... Ts> -inline constexpr bool holds_alternative(const U<Ts...> &v) noexcept +template <typename T, typename... Ts> +inline constexpr bool holds_alternative(const variant<Ts...> &v) noexcept { - // Clang 18.1.7 on Ubuntu 24.04 does not disambiguate between this - // and std::holds_alternative if argument type is std::variant<Ts...> - static_assert(std::is_same_v<U<Ts...>, std::variant<Ts...>>, - "Unsupported argument type"); return std::holds_alternative<T, Ts...>(v); } diff --git a/third_party/opentelemetry-cpp/api/include/opentelemetry/version.h b/third_party/opentelemetry-cpp/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.22.0" +#define OPENTELEMETRY_VERSION "1.23.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 22 +#define OPENTELEMETRY_VERSION_MINOR 23 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/third_party/opentelemetry-cpp/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h b/third_party/opentelemetry-cpp/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h @@ -81,11 +81,12 @@ public: } /** - * @param timeout an optional value containing the timeout of the exporter + * Attempt to shut down the in-memory span exporter. + * @param timeout Timeout is an optional value containing the timeout of the exporter * note: passing custom timeout values is not currently supported for this exporter * @return Returns the status of the operation */ - bool Shutdown(std::chrono::microseconds /* timeout */) noexcept override + bool Shutdown(std::chrono::microseconds timeout OPENTELEMETRY_MAYBE_UNUSED) noexcept override { is_shutdown_ = true; return true; diff --git a/third_party/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h b/third_party/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h @@ -6,6 +6,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -20,6 +21,7 @@ namespace v1 { class AnyValue; class KeyValue; +class InstrumentationScope; } // namespace v1 } // namespace common @@ -49,21 +51,27 @@ public: static void PopulateAttribute(opentelemetry::proto::resource::v1::Resource *proto, const opentelemetry::sdk::resource::Resource &resource) noexcept; + static void PopulateAttribute(opentelemetry::proto::common::v1::InstrumentationScope *proto, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope + &instrumentation_scope) noexcept; + static void PopulateAnyValue(opentelemetry::proto::common::v1::AnyValue *proto_value, - const opentelemetry::common::AttributeValue &value) noexcept; + const opentelemetry::common::AttributeValue &value, + bool allow_bytes) noexcept; - static void PopulateAnyValue( - opentelemetry::proto::common::v1::AnyValue *proto_value, - const opentelemetry::sdk::common::OwnedAttributeValue &value) noexcept; + static void PopulateAnyValue(opentelemetry::proto::common::v1::AnyValue *proto_value, + const opentelemetry::sdk::common::OwnedAttributeValue &value, + bool allow_bytes) noexcept; static void PopulateAttribute(opentelemetry::proto::common::v1::KeyValue *attribute, nostd::string_view key, - const opentelemetry::common::AttributeValue &value) noexcept; + const opentelemetry::common::AttributeValue &value, + bool allow_bytes) noexcept; - static void PopulateAttribute( - opentelemetry::proto::common::v1::KeyValue *attribute, - nostd::string_view key, - const opentelemetry::sdk::common::OwnedAttributeValue &value) noexcept; + static void PopulateAttribute(opentelemetry::proto::common::v1::KeyValue *attribute, + nostd::string_view key, + const opentelemetry::sdk::common::OwnedAttributeValue &value, + bool allow_bytes) noexcept; }; } // namespace otlp diff --git a/third_party/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h b/third_party/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h @@ -6,6 +6,7 @@ #include <memory> #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/version.h" @@ -49,6 +50,10 @@ public: static void PopulateRequest( const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans, proto::collector::trace::v1::ExportTraceServiceRequest *request) noexcept; + + static void PopulateRequest( + const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs, + proto::collector::logs::v1::ExportLogsServiceRequest *request) noexcept; }; } // namespace otlp } // namespace exporter diff --git a/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_populate_attribute_utils.cc b/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_populate_attribute_utils.cc @@ -3,7 +3,6 @@ #include <stdint.h> #include <string> -#include <type_traits> #include <unordered_map> #include <utility> #include <vector> @@ -12,9 +11,9 @@ #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/utility.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -41,7 +40,8 @@ const int kOwnedAttributeValueSize = 15; void OtlpPopulateAttributeUtils::PopulateAnyValue( opentelemetry::proto::common::v1::AnyValue *proto_value, - const opentelemetry::common::AttributeValue &value) noexcept + const opentelemetry::common::AttributeValue &value, + bool allow_bytes) noexcept { if (nullptr == proto_value) { @@ -90,10 +90,19 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( } else if (nostd::holds_alternative<nostd::span<const uint8_t>>(value)) { - auto array_value = proto_value->mutable_array_value(); - for (const auto &val : nostd::get<nostd::span<const uint8_t>>(value)) + if (allow_bytes) { - array_value->add_values()->set_int_value(val); + proto_value->set_bytes_value( + reinterpret_cast<const void *>(nostd::get<nostd::span<const uint8_t>>(value).data()), + nostd::get<nostd::span<const uint8_t>>(value).size()); + } + else + { + auto array_value = proto_value->mutable_array_value(); + for (const auto &val : nostd::get<nostd::span<const uint8_t>>(value)) + { + array_value->add_values()->set_int_value(val); + } } } else if (nostd::holds_alternative<nostd::span<const bool>>(value)) @@ -157,7 +166,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( void OtlpPopulateAttributeUtils::PopulateAnyValue( opentelemetry::proto::common::v1::AnyValue *proto_value, - const opentelemetry::sdk::common::OwnedAttributeValue &value) noexcept + const opentelemetry::sdk::common::OwnedAttributeValue &value, + bool allow_bytes) noexcept { if (nullptr == proto_value) { @@ -195,6 +205,23 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( { proto_value->set_double_value(nostd::get<double>(value)); } + else if (nostd::holds_alternative<std::vector<uint8_t>>(value)) + { + if (allow_bytes) + { + const std::vector<uint8_t> &byte_array = nostd::get<std::vector<uint8_t>>(value); + proto_value->set_bytes_value(reinterpret_cast<const void *>(byte_array.data()), + byte_array.size()); + } + else + { + auto array_value = proto_value->mutable_array_value(); + for (const auto &val : nostd::get<std::vector<uint8_t>>(value)) + { + array_value->add_values()->set_int_value(val); + } + } + } else if (nostd::holds_alternative<std::string>(value)) { proto_value->set_string_value(nostd::get<std::string>(value)); @@ -262,7 +289,8 @@ void OtlpPopulateAttributeUtils::PopulateAnyValue( void OtlpPopulateAttributeUtils::PopulateAttribute( opentelemetry::proto::common::v1::KeyValue *attribute, nostd::string_view key, - const opentelemetry::common::AttributeValue &value) noexcept + const opentelemetry::common::AttributeValue &value, + bool allow_bytes) noexcept { if (nullptr == attribute) { @@ -276,14 +304,15 @@ void OtlpPopulateAttributeUtils::PopulateAttribute( "AttributeValue contains unknown type"); attribute->set_key(key.data(), key.size()); - PopulateAnyValue(attribute->mutable_value(), value); + PopulateAnyValue(attribute->mutable_value(), value, allow_bytes); } /** Maps from C++ attribute into OTLP proto attribute. */ void OtlpPopulateAttributeUtils::PopulateAttribute( opentelemetry::proto::common::v1::KeyValue *attribute, nostd::string_view key, - const opentelemetry::sdk::common::OwnedAttributeValue &value) noexcept + const opentelemetry::sdk::common::OwnedAttributeValue &value, + bool allow_bytes) noexcept { if (nullptr == attribute) { @@ -297,7 +326,7 @@ void OtlpPopulateAttributeUtils::PopulateAttribute( "OwnedAttributeValue contains unknown type"); attribute->set_key(key.data(), key.size()); - PopulateAnyValue(attribute->mutable_value(), value); + PopulateAnyValue(attribute->mutable_value(), value, allow_bytes); } void OtlpPopulateAttributeUtils::PopulateAttribute( @@ -311,7 +340,20 @@ void OtlpPopulateAttributeUtils::PopulateAttribute( for (const auto &kv : resource.GetAttributes()) { - OtlpPopulateAttributeUtils::PopulateAttribute(proto->add_attributes(), kv.first, kv.second); + OtlpPopulateAttributeUtils::PopulateAttribute(proto->add_attributes(), kv.first, kv.second, + false); + } +} + +void OtlpPopulateAttributeUtils::PopulateAttribute( + opentelemetry::proto::common::v1::InstrumentationScope *proto, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope + &instrumentation_scope) noexcept +{ + for (const auto &kv : instrumentation_scope.GetAttributes()) + { + OtlpPopulateAttributeUtils::PopulateAttribute(proto->add_attributes(), kv.first, kv.second, + false); } } diff --git a/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_recordable.cc b/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_recordable.cc @@ -10,10 +10,10 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" +#include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/utility.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/trace/span_context.h" @@ -107,6 +107,7 @@ proto::common::v1::InstrumentationScope OtlpRecordable::GetProtoInstrumentationS { instrumentation_scope.set_name(instrumentation_scope_->GetName()); instrumentation_scope.set_version(instrumentation_scope_->GetVersion()); + OtlpPopulateAttributeUtils::PopulateAttribute(&instrumentation_scope, *instrumentation_scope_); } return instrumentation_scope; } @@ -120,7 +121,7 @@ void OtlpRecordable::SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept { auto *attribute = span_.add_attributes(); - OtlpPopulateAttributeUtils::PopulateAttribute(attribute, key, value); + OtlpPopulateAttributeUtils::PopulateAttribute(attribute, key, value, false); } void OtlpRecordable::AddEvent(nostd::string_view name, @@ -132,7 +133,7 @@ void OtlpRecordable::AddEvent(nostd::string_view name, event->set_time_unix_nano(timestamp.time_since_epoch().count()); attributes.ForEachKeyValue([&](nostd::string_view key, common::AttributeValue value) noexcept { - OtlpPopulateAttributeUtils::PopulateAttribute(event->add_attributes(), key, value); + OtlpPopulateAttributeUtils::PopulateAttribute(event->add_attributes(), key, value, false); return true; }); } @@ -147,7 +148,7 @@ void OtlpRecordable::AddLink(const trace::SpanContext &span_context, trace::SpanId::kSize); link->set_trace_state(span_context.trace_state()->ToHeader()); attributes.ForEachKeyValue([&](nostd::string_view key, common::AttributeValue value) noexcept { - OtlpPopulateAttributeUtils::PopulateAttribute(link->add_attributes(), key, value); + OtlpPopulateAttributeUtils::PopulateAttribute(link->add_attributes(), key, value, false); return true; }); } diff --git a/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_recordable_utils.cc b/third_party/opentelemetry-cpp/exporters/otlp/src/otlp_recordable_utils.cc @@ -1,7 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include <algorithm> #include <cstddef> #include <list> #include <memory> @@ -9,20 +8,23 @@ #include <utility> #include <vector> +#include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" #include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/version.h" // clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" #include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/logs/v1/logs.pb.h" #include "opentelemetry/proto/resource/v1/resource.pb.h" #include "opentelemetry/proto/trace/v1/trace.pb.h" #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep @@ -103,6 +105,9 @@ void OtlpRecordableUtils::PopulateRequest( proto::common::v1::InstrumentationScope instrumentation_scope_proto; instrumentation_scope_proto.set_name(input_scope_spans.first->GetName()); instrumentation_scope_proto.set_version(input_scope_spans.first->GetVersion()); + OtlpPopulateAttributeUtils::PopulateAttribute(&instrumentation_scope_proto, + *input_scope_spans.first); + *scope_spans->mutable_scope() = instrumentation_scope_proto; scope_spans->set_schema_url(input_scope_spans.first->GetSchemaURL()); } @@ -116,6 +121,66 @@ void OtlpRecordableUtils::PopulateRequest( } } +void OtlpRecordableUtils::PopulateRequest( + const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs, + proto::collector::logs::v1::ExportLogsServiceRequest *request) noexcept +{ + if (nullptr == request) + { + return; + } + + using logs_index_by_instrumentation_type = + std::unordered_map<const opentelemetry::sdk::instrumentationscope::InstrumentationScope *, + std::list<std::unique_ptr<OtlpLogRecordable>>, + InstrumentationScopePointerHasher, InstrumentationScopePointerEqual>; + std::unordered_map<const opentelemetry::sdk::resource::Resource *, + logs_index_by_instrumentation_type> + logs_index_by_resource; + + for (auto &recordable : logs) + { + auto rec = + std::unique_ptr<OtlpLogRecordable>(static_cast<OtlpLogRecordable *>(recordable.release())); + auto instrumentation = &rec->GetInstrumentationScope(); + auto resource = &rec->GetResource(); + + logs_index_by_resource[resource][instrumentation].emplace_back(std::move(rec)); + } + + for (auto &input_resource_log : logs_index_by_resource) + { + auto output_resource_log = request->add_resource_logs(); + for (auto &input_scope_log : input_resource_log.second) + { + auto output_scope_log = output_resource_log->add_scope_logs(); + for (auto &input_log_record : input_scope_log.second) + { + if (!output_resource_log->has_resource()) + { + OtlpPopulateAttributeUtils::PopulateAttribute(output_resource_log->mutable_resource(), + *input_resource_log.first); + output_resource_log->set_schema_url(input_resource_log.first->GetSchemaURL()); + } + + if (!output_scope_log->has_scope()) + { + auto proto_scope = output_scope_log->mutable_scope(); + if (proto_scope != nullptr) + { + proto_scope->set_name(input_scope_log.first->GetName()); + proto_scope->set_version(input_scope_log.first->GetVersion()); + + OtlpPopulateAttributeUtils::PopulateAttribute(proto_scope, *input_scope_log.first); + } + output_scope_log->set_schema_url(input_scope_log.first->GetSchemaURL()); + } + + *output_scope_log->add_log_records() = std::move(input_log_record->log_record()); + } + } + } +} } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/third_party/opentelemetry-cpp/moz.yaml b/third_party/opentelemetry-cpp/moz.yaml @@ -9,8 +9,8 @@ origin: description: The OpenTelemetry C++ Client url: https://opentelemetry.io/ - release: v1.22.0 (2025-07-12T00:11:41+02:00). - revision: v1.22.0 + release: v1.23.0 (2025-09-26T02:04:33+02:00). + revision: v1.23.0 license: Apache-2.0 license-file: LICENSE diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h @@ -181,7 +181,7 @@ private: { return {}; } - auto data = data_.get(); + AtomicUniquePtr<T> *data = data_.get(); if (tail_index < head_index) { return CircularBufferRange<AtomicUniquePtr<T>>{nostd::span<AtomicUniquePtr<T>>{ diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/custom_hash_equality.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/custom_hash_equality.h @@ -0,0 +1,157 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include <cstddef> +#include <cstring> +#include <string> + +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace common +{ +/** + * + * FNV Hashing Utilities + * + * Implements FNV-1a hashing algorithm for 32-bit and 64-bit types. + * + * - FNV (Fowler–Noll–Vo) is a simple, fast, and widely used non-cryptographic hash. + * - FNV-1a is the recommended variant because it mixes input bits better. + * - We parameterize by type size (4 = 32-bit, 8 = 64-bit). + */ + +// Forward declaration for FNV prime constants +template <typename Ty, size_t Size> +struct FnvPrime; + +// Specialization for 32-bit +template <typename Ty> +struct FnvPrime<Ty, 4> +{ + static constexpr Ty value = static_cast<Ty>(0x01000193U); +}; + +// Specialization for 64-bit +template <typename Ty> +struct FnvPrime<Ty, 8> +{ + static constexpr Ty value = static_cast<Ty>(0x100000001b3ULL); +}; + +// Forward declaration for FNV offset basis constants +template <typename Ty, size_t Size> +struct FnvOffset; + +// Specialization for 32-bit +template <typename Ty> +struct FnvOffset<Ty, 4> +{ + // 32-bit offset basis + static constexpr Ty value = static_cast<Ty>(0x811C9DC5U); + + static constexpr Ty Fix(Ty hval) noexcept { return hval; } +}; + +// Specialization for 64-bit +template <typename Ty> +struct FnvOffset<Ty, 8> +{ + // 64-bit offset basis + static constexpr Ty value = static_cast<Ty>(0xCBF29CE484222325ULL); + + // Fix function: mix upper and lower bits for better distribution + static constexpr Ty Fix(Ty hval) noexcept { return hval ^ (hval >> 32); } +}; + +/** + * FNV-1a hash function + * + * @tparam Ty Hash integer type (std::size_t, uint32_t, uint64_t, etc.) + * @param buf Pointer to the input buffer + * @param len Length of the buffer + * @param hval Starting hash value (defaults to offset basis) + * @return Computed hash + */ +template <typename Ty> +inline Ty Fnv1a(const void *buf, size_t len, Ty hval = FnvOffset<Ty, sizeof(Ty)>::value) noexcept +{ + const unsigned char *bp = reinterpret_cast<const unsigned char *>(buf); + const unsigned char *be = bp + len; + Ty prime = FnvPrime<Ty, sizeof(Ty)>::value; + + while (bp < be) + { + hval ^= static_cast<Ty>(*bp++); + hval *= prime; + } + return FnvOffset<Ty, sizeof(Ty)>::Fix(hval); +} + +/** + * Hash and equality for nostd::string_view, enabling safe use in unordered_map + * without requiring null termination. + */ + +struct StringViewHash +{ +#if defined(OPENTELEMETRY_STL_VERSION) +# if OPENTELEMETRY_STL_VERSION >= 2020 + using is_transparent = void; +# endif +#endif + + std::size_t operator()(const std::string &s) const noexcept + { + return Fnv1a<std::size_t>(s.data(), s.size()); + } + + std::size_t operator()(opentelemetry::nostd::string_view sv) const noexcept + { + return Fnv1a<std::size_t>(sv.data(), sv.size()); + } +}; + +struct StringViewEqual +{ +#if defined(OPENTELEMETRY_STL_VERSION) +# if OPENTELEMETRY_STL_VERSION >= 2020 + using is_transparent = void; +# endif +#endif + + template <typename Lhs, typename Rhs> + bool operator()(const Lhs &lhs, const Rhs &rhs) const noexcept + { + opentelemetry::nostd::string_view lsv(lhs); + opentelemetry::nostd::string_view rsv(rhs); + + return lsv.size() == rsv.size() && std::memcmp(lsv.data(), rsv.data(), lsv.size()) == 0; + } +}; + +/** + * Cross-platform heterogeneous lookup wrapper. + * Falls back to std::string construction on libc++ (macOS) and pre-c++20, + * but uses direct lookup on libstdc++ (Linux). + */ + +template <typename MapType> +inline auto find_heterogeneous(MapType &&map, opentelemetry::nostd::string_view key) +{ +#if defined(_LIBCPP_VERSION) || \ + (!defined(OPENTELEMETRY_STL_VERSION) || OPENTELEMETRY_STL_VERSION < 2020) + return map.find(std::string(key)); +#else + // libstdc++ + C++20: heterogeneous lookup works + return map.find(key); +#endif +} +} // namespace common +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h @@ -19,7 +19,14 @@ using ResourceAttributes = opentelemetry::sdk::common::AttributeMap; class Resource { public: - Resource(const Resource &) = default; + Resource() noexcept; + + Resource(const ResourceAttributes &attributes) noexcept; + + Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept; + + Resource(const Resource &) = default; + Resource &operator=(const Resource &) = default; const ResourceAttributes &GetAttributes() const noexcept; const std::string &GetSchemaURL() const noexcept; @@ -61,21 +68,9 @@ public: static Resource &GetDefault(); -protected: - /** - * The constructor is protected and only for use internally by the class and - * inside ResourceDetector class. - * Users should use the Create factory method to obtain a Resource - * instance. - */ - Resource(const ResourceAttributes &attributes = ResourceAttributes(), - const std::string &schema_url = std::string{}) noexcept; - private: ResourceAttributes attributes_; std::string schema_url_; - - friend class ResourceDetector; }; } // namespace resource diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h @@ -124,6 +124,19 @@ public: bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override { + return InternalShutdown(timeout); + } + + ~MultiSpanProcessor() override + { + InternalShutdown(); + Cleanup(); + } + +protected: + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept + { bool result = true; ProcessorNode *node = head_; while (node != nullptr) @@ -135,12 +148,6 @@ public: return result; } - ~MultiSpanProcessor() override - { - Shutdown(); - Cleanup(); - } - private: struct ProcessorNode { diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h @@ -77,6 +77,15 @@ public: bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override { + return InternalShutdown(timeout); + } + + ~SimpleSpanProcessor() override { InternalShutdown(); } + +protected: + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept + { // We only call shutdown ONCE. if (exporter_ != nullptr && !shutdown_latch_.test_and_set(std::memory_order_acquire)) { @@ -85,8 +94,6 @@ public: return true; } - ~SimpleSpanProcessor() override { Shutdown(); } - private: std::unique_ptr<SpanExporter> exporter_; opentelemetry::common::SpinLockMutex lock_; diff --git a/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h b/third_party/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.22.0" +#define OPENTELEMETRY_SDK_VERSION "1.23.0" #include "opentelemetry/version.h" diff --git a/third_party/opentelemetry-cpp/sdk/src/resource/resource.cc b/third_party/opentelemetry-cpp/sdk/src/resource/resource.cc @@ -20,6 +20,12 @@ namespace sdk namespace resource { +Resource::Resource() noexcept : attributes_(), schema_url_() {} + +Resource::Resource(const ResourceAttributes &attributes) noexcept + : attributes_(attributes), schema_url_() +{} + Resource::Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept : attributes_(attributes), schema_url_(schema_url) {} diff --git a/third_party/opentelemetry-cpp/sdk/src/resource/resource_detector.cc b/third_party/opentelemetry-cpp/sdk/src/resource/resource_detector.cc @@ -19,8 +19,8 @@ namespace sdk namespace resource { -const char *OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES"; -const char *OTEL_SERVICE_NAME = "OTEL_SERVICE_NAME"; +constexpr const char *kOtelResourceAttributes = "OTEL_RESOURCE_ATTRIBUTES"; +constexpr const char *kOtelServiceName = "OTEL_SERVICE_NAME"; Resource ResourceDetector::Create(const ResourceAttributes &attributes, const std::string &schema_url) @@ -33,9 +33,9 @@ Resource OTELResourceDetector::Detect() noexcept std::string attributes_str, service_name; bool attributes_exists = opentelemetry::sdk::common::GetStringEnvironmentVariable( - OTEL_RESOURCE_ATTRIBUTES, attributes_str); + kOtelResourceAttributes, attributes_str); bool service_name_exists = - opentelemetry::sdk::common::GetStringEnvironmentVariable(OTEL_SERVICE_NAME, service_name); + opentelemetry::sdk::common::GetStringEnvironmentVariable(kOtelServiceName, service_name); if (!attributes_exists && !service_name_exists) { diff --git a/third_party/opentelemetry-cpp/sdk/src/version/version.cc b/third_party/opentelemetry-cpp/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 22; +const int minor_version = 23; const int patch_version = 0; -const char *pre_release = "NONE"; -const char *build_metadata = "NONE"; -const char *short_version = "1.22.0"; -const char *full_version = "1.22.0-NONE-NONE"; -const char *build_date = "Fri Jul 11 08:13:24 PM UTC 2025"; +const char *pre_release = ""; +const char *build_metadata = "none"; +const char *short_version = "1.23.0"; +const char *full_version = "1.23.0"; +const char *build_date = "Thu Sep 25 07:47:31 PM UTC 2025"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE