Skip to content
Closed
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ Increment the:
* [CMAKE] Add generated protobuf headers to the opentelemetry_proto target
[#3400](https://github.com/open-telemetry/opentelemetry-cpp/pull/3400)

* [SDK] Fix lifetime for sdk::ReadWriteLogRecord
[#3147](https://github.com/open-telemetry/opentelemetry-cpp/pull/3245)

Important changes:

* [SDK] Fix lifetime for sdk::ReadWriteLogRecord
[#3147](https://github.com/open-telemetry/opentelemetry-cpp/pull/3245)

* `opentelemetry::sdk::logs::ReadableLogRecord::GetAttributes()`
will returns a `std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>`
instead of a `std::unordered_map<std::string, opentelemetry::common::AttributeValue>`
to keep the same type as the `opentelemetry::sdk::trace::SpanData`. And
`opentelemetry::sdk::logs::ReadableLogRecord::GetBody()` will returns a
`const opentelemetry::sdk::common::OwnedAttributeValue &` instead of a
`const opentelemetry::common::AttributeValue &` now, we switch to the old
APIs by add `-DWITH_DEPRECATED_SDK_LOG_RECORD=ON` for cmake or add
`--copt -DOPENTELEMETRY_DEPRECATED_SDK_LOG_RECORD` for bazel.

## [1.20 2025-04-01]

* [BUILD] Update opentelemetry-proto version
Expand Down Expand Up @@ -199,6 +217,9 @@ Important changes:

* All the example code has been updated to reflect the new usage.

* [SDK] Implement spec: MetricFilter
[#3235](https://github.com/open-telemetry/opentelemetry-cpp/pull/3235)

## [1.19 2025-01-22]

* [PROMETHEUS_EXPORTER] Fix default for emitting otel_scope attributes
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
endif()

option(WITH_ABI_VERSION_1 "ABI version 1" ON)
include(CMakeDependentOption)
option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF)
cmake_dependent_option(WITH_ABI_VERSION_1 "ABI version 1" ON
"NOT WITH_ABI_VERSION_2" OFF)

file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h"
OPENTELEMETRY_CPP_HEADER_VERSION_H)
Expand Down Expand Up @@ -183,6 +185,13 @@ message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}")

option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF)

option(WITH_DEPRECATED_SDK_LOG_RECORD "Use deprecated SDK log record" OFF)

if(WITH_DEPRECATED_SDK_LOG_RECORD)
message(
WARNING "WITH_DEPRECATED_SDK_LOG_RECORD=ON is temporary and deprecated")
endif()

set(WITH_STL
"OFF"
CACHE STRING "Which version of the Standard Library for C++ to use")
Expand Down Expand Up @@ -490,7 +499,6 @@ if(WITH_OTLP_GRPC
# Some versions of FindProtobuf.cmake uses mixed case instead of uppercase
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
endif()
include(CMakeDependentOption)

message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
Expand Down
2 changes: 2 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ switch ($action) {
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DOPENTELEMETRY_BUILD_DLL=1 `
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
Expand Down Expand Up @@ -221,6 +222,7 @@ switch ($action) {
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
Expand Down
5 changes: 5 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ elif [[ "$1" == "cmake.with_async_export.test" ]]; then
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON \
"${SRC_DIR}"
make -j $(nproc)
make test
Expand Down Expand Up @@ -281,6 +282,7 @@ elif [[ "$1" == "cmake.c++20.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX20 \
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -292,6 +294,7 @@ elif [[ "$1" == "cmake.c++23.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX23 \
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -304,6 +307,7 @@ elif [[ "$1" == "cmake.c++14.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX14 \
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -316,6 +320,7 @@ elif [[ "$1" == "cmake.c++17.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX17 \
-DWITH_DEPRECATED_SDK_LOG_RECORD=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand Down
8 changes: 4 additions & 4 deletions exporters/ostream/src/log_record_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "opentelemetry/sdk/common/exporter_utils.h"
#include "opentelemetry/sdk/common/global_log_handler.h"
#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
#include "opentelemetry/sdk/logs/read_write_log_record.h"
#include "opentelemetry/sdk/logs/log_record_data.h"
#include "opentelemetry/sdk/logs/recordable.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/trace/span_id.h"
Expand All @@ -47,7 +47,7 @@ OStreamLogRecordExporter::OStreamLogRecordExporter(std::ostream &sout) noexcept

std::unique_ptr<sdklogs::Recordable> OStreamLogRecordExporter::MakeRecordable() noexcept
{
return std::unique_ptr<sdklogs::Recordable>(new sdklogs::ReadWriteLogRecord());
return std::unique_ptr<sdklogs::Recordable>(new sdklogs::LogRecordData());
}

sdk::common::ExportResult OStreamLogRecordExporter::Export(
Expand All @@ -62,8 +62,8 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export(

for (auto &record : records)
{
auto log_record = std::unique_ptr<sdklogs::ReadWriteLogRecord>(
static_cast<sdklogs::ReadWriteLogRecord *>(record.release()));
auto log_record = std::unique_ptr<sdklogs::LogRecordData>(
static_cast<sdklogs::LogRecordData *>(record.release()));

if (log_record == nullptr)
{
Expand Down
22 changes: 11 additions & 11 deletions exporters/ostream/test/ostream_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include "opentelemetry/nostd/utility.h"
#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
#include "opentelemetry/sdk/logs/exporter.h"
#include "opentelemetry/sdk/logs/log_record_data.h"
#include "opentelemetry/sdk/logs/logger_provider.h"
#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/sdk/logs/provider.h"
#include "opentelemetry/sdk/logs/read_write_log_record.h"
#include "opentelemetry/sdk/logs/readable_log_record.h"
#include "opentelemetry/sdk/logs/recordable.h"
#include "opentelemetry/sdk/logs/simple_log_record_processor.h"
Expand Down Expand Up @@ -82,7 +82,7 @@ TEST(OStreamLogRecordExporter, Shutdown)

// After processor/exporter is shutdown, no logs should be sent to stream
auto record = exporter->MakeRecordable();
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetBody("Log record not empty");
static_cast<sdklogs::LogRecordData *>(record.get())->SetBody("Log record not empty");
exporter->Export(nostd::span<std::unique_ptr<sdklogs::Recordable>>(&record, 1));

// Restore original stringstream buffer
Expand Down Expand Up @@ -171,12 +171,12 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout)
// Create a log record and manually timestamp, severity, name, message
common::SystemTimestamp now(std::chrono::system_clock::now());

auto record = std::unique_ptr<sdklogs::Recordable>(new sdklogs::ReadWriteLogRecord());
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetTimestamp(now);
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetObservedTimestamp(now);
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())
auto record = std::unique_ptr<sdklogs::Recordable>(new sdklogs::LogRecordData());
static_cast<sdklogs::LogRecordData *>(record.get())->SetTimestamp(now);
static_cast<sdklogs::LogRecordData *>(record.get())->SetObservedTimestamp(now);
static_cast<sdklogs::LogRecordData *>(record.get())
->SetSeverity(logs_api::Severity::kTrace); // kTrace has enum value of 1
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetBody("Message");
static_cast<sdklogs::LogRecordData *>(record.get())->SetBody("Message");

opentelemetry::sdk::instrumentationscope::InstrumentationScope instrumentation_scope =
GetTestInstrumentationScope();
Expand Down Expand Up @@ -248,10 +248,10 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr)

// Set resources for this log record only of type <string, string>
auto resource = opentelemetry::sdk::resource::Resource::Create({{"key1", "val1"}});
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetResource(resource);
static_cast<sdklogs::LogRecordData *>(record.get())->SetResource(resource);

// Set attributes to this log record of type <string, AttributeValue>
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetAttribute("a", true);
static_cast<sdklogs::LogRecordData *>(record.get())->SetAttribute("a", true);

opentelemetry::sdk::instrumentationscope::InstrumentationScope instrumentation_scope =
GetTestInstrumentationScope();
Expand Down Expand Up @@ -326,12 +326,12 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog)
nostd::span<int> data1{array1.data(), array1.size()};

auto resource = opentelemetry::sdk::resource::Resource::Create({{"res1", data1}});
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())->SetResource(resource);
static_cast<sdklogs::LogRecordData *>(record.get())->SetResource(resource);

// Set resources for this log record of bool types as the value
// e.g. key/value is a par of type <string, array of bools>
std::array<bool, 3> array = {false, true, false};
static_cast<sdklogs::ReadWriteLogRecord *>(record.get())
static_cast<sdklogs::LogRecordData *>(record.get())
->SetAttribute("attr1", nostd::span<bool>{array.data(), array.size()});

opentelemetry::sdk::instrumentationscope::InstrumentationScope instrumentation_scope =
Expand Down
Loading
Loading