From f7fb5742a91be48aa0eca836cde4ab73e20463cd Mon Sep 17 00:00:00 2001 From: Karen Xu Date: Mon, 30 Nov 2020 07:17:46 -0500 Subject: [PATCH] Add Ostream log exporter and tests --- exporters/ostream/BUILD | 24 ++ exporters/ostream/CMakeLists.txt | 20 +- .../exporters/ostream/log_exporter.h | 45 +++ exporters/ostream/src/log_exporter.cc | 62 ++++ exporters/ostream/test/ostream_log_test.cc | 272 ++++++++++++++++++ sdk/include/opentelemetry/sdk/logs/exporter.h | 2 +- .../opentelemetry/sdk/logs/processor.h | 2 +- .../sdk/logs/simple_log_processor.h | 7 +- sdk/src/logs/logger.cc | 4 +- sdk/src/logs/simple_log_processor.cc | 19 +- sdk/test/logs/logger_provider_sdk_test.cc | 6 +- sdk/test/logs/logger_sdk_test.cc | 41 --- sdk/test/logs/simple_log_processor_test.cc | 4 +- 13 files changed, 441 insertions(+), 67 deletions(-) create mode 100644 exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h create mode 100644 exporters/ostream/src/log_exporter.cc create mode 100644 exporters/ostream/test/ostream_log_test.cc diff --git a/exporters/ostream/BUILD b/exporters/ostream/BUILD index e2d7c206ea..e40fa5a883 100644 --- a/exporters/ostream/BUILD +++ b/exporters/ostream/BUILD @@ -1,5 +1,29 @@ package(default_visibility = ["//visibility:public"]) +cc_library( + name = "ostream_log_exporter", + srcs = [ + "src/log_exporter.cc", + ], + hdrs = [ + "include/opentelemetry/exporters/ostream/log_exporter.h", + ], + strip_include_prefix = "include", + deps = [ + "//sdk/src/logs", + "//sdk/src/trace", + ], +) + +cc_test( + name = "ostream_log_test", + srcs = ["test/ostream_log_test.cc"], + deps = [ + ":ostream_log_exporter", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "ostream_metrics_exporter", srcs = [ diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index b6faccf513..8a783c0c42 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -1,11 +1,13 @@ include_directories(include) +add_library(opentelemetry_exporter_ostream_logs src/log_exporter.cc) add_library(opentelemetry_exporter_ostream_metrics src/metrics_exporter.cc) add_library(opentelemetry_exporter_ostream_span src/span_exporter.cc) if(BUILD_TESTING) add_executable(ostream_metrics_test test/ostream_metrics_test.cc) add_executable(ostream_span_test test/ostream_span_test.cc) + add_executable(ostream_log_test test/ostream_log_test.cc) target_link_libraries( ostream_span_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} @@ -15,12 +17,14 @@ if(BUILD_TESTING) ostream_metrics_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} opentelemetry_exporter_ostream_metrics) - gtest_add_tests( - TARGET ostream_metrics_test - TEST_PREFIX exporter. - TEST_LIST ostream_metrics_test) - gtest_add_tests( - TARGET ostream_span_test - TEST_PREFIX exporter. - TEST_LIST ostream_span_test) + target_link_libraries( + ostream_log_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + opentelemetry_exporter_ostream_logs opentelemetry_logs) + + gtest_add_tests(TARGET ostream_log_test TEST_PREFIX exporter. TEST_LIST + ostream_log_test) + gtest_add_tests(TARGET ostream_metrics_test TEST_PREFIX exporter. TEST_LIST + ostream_metrics_test) + gtest_add_tests(TARGET ostream_span_test TEST_PREFIX exporter. TEST_LIST + ostream_span_test) endif() # BUILD_TESTING diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h new file mode 100644 index 0000000000..30bae60746 --- /dev/null +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h @@ -0,0 +1,45 @@ +#pragma once + +// #include "nlohmann/json.hpp" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/type_traits.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" // needed? + +#include +#include +#include + +namespace nostd = opentelemetry::nostd; +namespace sdklogs = opentelemetry::sdk::logs; + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace logs +{ +/** + * The OStreamLogExporter exports logs through an ostream (default set to std::cout) + */ +class OStreamLogExporter final : public sdklogs::LogExporter +{ +public: + /** + * Create an OStreamLogExporter. This constructor takes in a reference to an ostream that the + * export() function will send log data into. + * The default ostream is set to stdout + */ + explicit OStreamLogExporter(std::ostream &sout = std::cout) noexcept; + sdklogs::ExportResult Export(const nostd::span> & + records) noexcept override; + + bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + +private: + std::ostream &sout_; + bool isShutdown_ = false; + bool firstLog = true; +}; +} // namespace logs +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/ostream/src/log_exporter.cc b/exporters/ostream/src/log_exporter.cc new file mode 100644 index 0000000000..9553c234be --- /dev/null +++ b/exporters/ostream/src/log_exporter.cc @@ -0,0 +1,62 @@ +#include "opentelemetry/exporters/ostream/log_exporter.h" + +#include + +namespace nostd = opentelemetry::nostd; +namespace sdklogs = opentelemetry::sdk::logs; + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace logs +{ +OStreamLogExporter::OStreamLogExporter(std::ostream &sout) noexcept : sout_(sout) {} + +sdklogs::ExportResult OStreamLogExporter::Export( + const nostd::span> & records) noexcept +{ + if (isShutdown_) + { + return sdklogs::ExportResult::kFailure; + } + + for (auto &record : records) + { + // Convert trace, spanid, traceflags into string convertable representation + char trace_id[32] = {0}; + record->trace_id.ToLowerBase16(trace_id); + + char span_id[16] = {0}; + record->span_id.ToLowerBase16(span_id); + + char trace_flags[2] = {0}; + record->trace_flags.ToLowerBase16(trace_flags); + + // Print out each field of the log record + + sout_ << "{\n" + << " timestamp : " << record->timestamp.time_since_epoch().count() << "\n" + << " severity : " << static_cast(record->severity) << "\n" + << " name : " << record->name << "\n" + << " body : " << record->body + << "\n" + // << " resource : " << record->resource << "\n" + // << " attributes : " << record->attributes << "\n" + << " trace_id : " << std::string(trace_id, 32) << "\n" + << " span_id : " << std::string(span_id, 16) << "\n" + << " trace_flags : " << std::string(trace_flags, 2) << "\n" + << "}\n"; + } + + return sdklogs::ExportResult::kSuccess; +} + +bool OStreamLogExporter::Shutdown(std::chrono::microseconds timeout) noexcept +{ + isShutdown_ = true; + return true; +} + +} // namespace logs +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc new file mode 100644 index 0000000000..bad48e7fe5 --- /dev/null +++ b/exporters/ostream/test/ostream_log_test.cc @@ -0,0 +1,272 @@ +#include "opentelemetry/exporters/ostream/log_exporter.h" +#include "opentelemetry/logs/provider.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/simple_log_processor.h" + +#include +#include + +#include +#include + +namespace sdklogs = opentelemetry::sdk::logs; +namespace logs_api = opentelemetry::logs; +namespace nostd = opentelemetry::nostd; + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace logs +{ + +// Test that processor/exporter is shutdown, no logs should be sent to stream +TEST(OStreamLogExporter, Shutdown) +{ + auto exporter = + std::unique_ptr(new opentelemetry::exporter::logs::OStreamLogExporter); + auto processor = + std::shared_ptr(new sdklogs::SimpleLogProcessor(std::move(exporter))); + + auto record = std::shared_ptr(new logs_api::LogRecord()); + record->name = "Test Log"; + + // Create stringstream to redirect to + std::stringstream stdoutOutput; + + // Save cout's buffer here + std::streambuf *sbuf = std::cout.rdbuf(); + + // Redirect cout to our stringstream buffer + std::cout.rdbuf(stdoutOutput.rdbuf()); + + processor->Shutdown(); + + // After processor/exporter is shutdown, no logs should be sent to stream + processor->OnReceive(record); + + std::cout.rdbuf(sbuf); + + ASSERT_EQ(stdoutOutput.str(), ""); +} + +// ---------------------------------- Print to cout, cerr, and clog ------------------------- + +// Print Log to std::cout +TEST(OStreamLogExporter, PrintLogToCout) +{ + // Initialize an Ostream exporter to cout + auto exporter = std::unique_ptr( + new opentelemetry::exporter::logs::OStreamLogExporter(std::cout)); + auto processor = + std::shared_ptr(new sdklogs::SimpleLogProcessor(std::move(exporter))); + + // Save original stream buffer and redirect cout to our new stream buffer + std::streambuf *sbuf = std::cout.rdbuf(); + std::stringstream stdcoutOutput; + std::cout.rdbuf(stdcoutOutput.rdbuf()); + + // Create a log record and manually set all fields (since we are not using SDK to inject fields) + opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::trace::SpanId span_id; + opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::TraceFlags trace_flags; + + auto record = std::shared_ptr(new logs_api::LogRecord()); + record->timestamp = now; + record->severity = logs_api::Severity::kInfo; + record->name = "Test Log"; + record->body = "Message"; + record->trace_id = trace_id; + record->span_id = span_id; + record->trace_flags= trace_flags; + + // Log a record to cout + processor->OnReceive(record); + + // Reset cout's original stringstream buffer + std::cout.rdbuf(sbuf); + + std::string expectedOutput = + "{\n" + " timestamp : " + + std::to_string(now.time_since_epoch().count()) + + "\n" + " severity : 9\n" + " name : Test Log\n" + " body : Message\n" + " trace_id : 00000000000000000000000000000000\n" + " span_id : 0000000000000000\n" + " trace_flags : 00\n" + // " resource : []\n" + // " attributes : []\n" + "}\n"; + ASSERT_EQ(stdcoutOutput.str(), expectedOutput); +} + +// Print log to std::cerr +TEST(OStreamLogExporter, PrintLogToCerr) +{ + // Initialize an Ostream exporter to cerr + auto exporter = std::unique_ptr( + new opentelemetry::exporter::logs::OStreamLogExporter(std::cerr)); + auto processor = + std::shared_ptr(new sdklogs::SimpleLogProcessor(std::move(exporter))); + + // Save original stream buffer and redirect cerr to our new stream buffer + std::streambuf *sbuf = std::cerr.rdbuf(); + std::stringstream stdcerrOutput; + std::cerr.rdbuf(stdcerrOutput.rdbuf()); + + // Create a log record and manually set all fields (since we are not using SDK to inject fields) + opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::trace::SpanId span_id; + opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::TraceFlags trace_flags; + + auto record = std::shared_ptr(new logs_api::LogRecord()); + record->timestamp = now; + record->severity = logs_api::Severity::kInfo; + record->name = "Test Log"; + record->body = "Message"; + record->trace_id = trace_id; + record->span_id = span_id; + record->trace_flags= trace_flags; + + // Log a record to cerr + processor->OnReceive(record); + + // Reset cerr's original stringstream buffer + std::cerr.rdbuf(sbuf); + + std::string expectedOutput = + "{\n" + " timestamp : " + + std::to_string(now.time_since_epoch().count()) + + "\n" + " severity : 9\n" + " name : Test Log\n" + " body : Message\n" + " trace_id : 00000000000000000000000000000000\n" + " span_id : 0000000000000000\n" + " trace_flags : 00\n" + // " resource : []\n" + // " attributes : []\n" + "}\n"; + ASSERT_EQ(stdcerrOutput.str(), expectedOutput); +} + +// Pirnt log to std::clog +TEST(OStreamLogExporter, PrintLogToClog) +{ + // Initialize an ostream exporter to clog + auto exporter = std::unique_ptr( + new opentelemetry::exporter::logs::OStreamLogExporter(std::clog)); + auto processor = + std::shared_ptr(new sdklogs::SimpleLogProcessor(std::move(exporter))); + + // Save original stream buffer and redirect clog to our new stream buffer + std::streambuf *sbuf = std::clog.rdbuf(); + std::stringstream stdcerrOutput; + std::clog.rdbuf(stdcerrOutput.rdbuf()); + + // Create a log record and manually set all fields (since we are not using SDK to inject fields) + opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::trace::SpanId span_id; + opentelemetry::trace::TraceId trace_id; + opentelemetry::trace::TraceFlags trace_flags; + + auto record = std::shared_ptr(new logs_api::LogRecord()); + record->timestamp = now; + record->severity = logs_api::Severity::kInfo; // kInfo = 9 + record->name = "Test Log"; + record->body = "Message"; + record->trace_id = trace_id; + record->span_id = span_id; + record->trace_flags= trace_flags; + + // Log a record to clog + processor->OnReceive(record); + + // Reset clog's original stringstream buffer + std::clog.rdbuf(sbuf); + + std::string expectedOutput = + "{\n" + " timestamp : " + + std::to_string(now.time_since_epoch().count()) + + "\n" + " severity : 9\n" + " name : Test Log\n" + " body : Message\n" + " trace_id : 00000000000000000000000000000000\n" + " span_id : 0000000000000000\n" + " trace_flags : 00\n" + // " resource : []\n" + // " attributes : []\n" + "}\n"; + ASSERT_EQ(stdcerrOutput.str(), expectedOutput); +} + +// ---------------------------------- Integration Tests ------------------------- + +// Print a log using the full logging pipeline +TEST(OStreamLogExporter, IntegrationTest) +{ + // Initialize a logger + auto exporter = + std::unique_ptr(new opentelemetry::exporter::logs::OStreamLogExporter); + auto processor = + std::shared_ptr(new sdklogs::SimpleLogProcessor(std::move(exporter))); + auto sdkProvider = std::shared_ptr(new sdklogs::LoggerProvider()); + sdkProvider->SetProcessor(processor); + auto apiProvider = nostd::shared_ptr(sdkProvider); + auto provider = nostd::shared_ptr(apiProvider); + logs_api::Provider::SetLoggerProvider(provider); + auto logger = logs_api::Provider::GetLoggerProvider()->GetLogger("Logger"); + + // Back up cout's streambuf + std::streambuf *sbuf = std::cout.rdbuf(); + + // Redirect cout to our string stream + std::stringstream stdcoutOutput; + std::cout.rdbuf(stdcoutOutput.rdbuf()); + + // Write a log to ostream exporter + // auto record = std::shared_ptr(new logs_api::LogRecord()); + logs_api::LogRecord record; + opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + record.timestamp = now; + record.severity = logs_api::Severity::kInfo; + record.body = "Test Log"; + logger->Log(record); + + // logger->Log("Test Log"); + + // Restore cout's original streambuf + std::cout.rdbuf(sbuf); + + // Compare actual vs expected outputs + std::string expectedOutput = + "{\n" + " timestamp : " + + std::to_string(now.time_since_epoch().count()) + + "\n" // how to check? + " severity : 9\n" + " name : \n" + " body : Test Log\n" + " trace_id : 00000000000000000000000000000000\n" + " span_id : 0000000000000000\n" + " trace_flags : 00\n" + // " resource : []\n" + // " attributes : []\n" + "}\n"; + + ASSERT_EQ(stdcoutOutput.str(), expectedOutput); +} + +// TODO: Test behavior when a log record that is already sent to the processor is logged (unintended +// use) + +} // namespace logs +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/logs/exporter.h b/sdk/include/opentelemetry/sdk/logs/exporter.h index 6f44d32a28..e550ed40b3 100644 --- a/sdk/include/opentelemetry/sdk/logs/exporter.h +++ b/sdk/include/opentelemetry/sdk/logs/exporter.h @@ -55,7 +55,7 @@ class LogExporter * @returns an ExportResult code (whether export was success or failure) */ virtual ExportResult Export( - const nostd::span> &records) noexcept = 0; + const nostd::span> &records) noexcept = 0; /** * Marks the exporter as ShutDown and cleans up any resources as required. diff --git a/sdk/include/opentelemetry/sdk/logs/processor.h b/sdk/include/opentelemetry/sdk/logs/processor.h index 7468548dcf..bb3ad3c08e 100644 --- a/sdk/include/opentelemetry/sdk/logs/processor.h +++ b/sdk/include/opentelemetry/sdk/logs/processor.h @@ -38,7 +38,7 @@ class LogProcessor * OnReceive is called by the SDK once a log record has been successfully created. * @param record the log record */ - virtual void OnReceive(std::unique_ptr &&record) noexcept = 0; + virtual void OnReceive(std::shared_ptr record) noexcept = 0; /** * Exports all log records that have not yet been exported to the configured Exporter. diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h index 18ed28b2cf..3c64d48c98 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h @@ -43,13 +43,12 @@ class SimpleLogProcessor : public LogProcessor explicit SimpleLogProcessor(std::unique_ptr &&exporter); virtual ~SimpleLogProcessor() = default; - void OnReceive(std::unique_ptr &&record) noexcept override; + void OnReceive(std::shared_ptr record) noexcept override; bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept override; - bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept override; private: // The configured exporter diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index bc19f5d1c1..8104797c8c 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -42,7 +42,7 @@ void Logger::log(const opentelemetry::logs::LogRecord &record) noexcept * converting record a heap variable can be removed */ auto record_pointer = - std::unique_ptr(new opentelemetry::logs::LogRecord(record)); + std::shared_ptr(new opentelemetry::logs::LogRecord(record)); // TODO: Do not want to overwrite user-set timestamp if there already is one - // add a flag in the API to check if timestamp is set by user already before setting timestamp @@ -52,7 +52,7 @@ void Logger::log(const opentelemetry::logs::LogRecord &record) noexcept // TODO: inject traceid/spanid later // Send the log record to the processor - processor->OnReceive(std::move(record_pointer)); + processor->OnReceive(record_pointer); } } // namespace logs diff --git a/sdk/src/logs/simple_log_processor.cc b/sdk/src/logs/simple_log_processor.cc index d88fc9eb92..3793bf10ab 100644 --- a/sdk/src/logs/simple_log_processor.cc +++ b/sdk/src/logs/simple_log_processor.cc @@ -36,16 +36,16 @@ SimpleLogProcessor::SimpleLogProcessor(std::unique_ptr &&exporter) * Batches the log record it receives in a batch of 1 and immediately sends it * to the configured exporter */ -void SimpleLogProcessor::OnReceive( - std::unique_ptr &&record) noexcept +void SimpleLogProcessor::OnReceive(std::shared_ptr record) noexcept { - nostd::span> batch(&record, 1); + std::vector> batch; + batch.emplace_back(record); // Get lock to ensure Export() is never called concurrently const std::lock_guard locked(lock_); - if (exporter_->Export(batch) != ExportResult::kSuccess) + if (exporter_->Export(opentelemetry::nostd::span>(batch.data(), batch.size())) != ExportResult::kSuccess) { - /* Alert user of the failed export */ + /* TODO: alert user of the failed or timedout export result */ } } /** @@ -56,8 +56,17 @@ bool SimpleLogProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept return true; } +/** + * TODO: This method should not block indefinitely. Should abort within timeout. + */ bool SimpleLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { + if (timeout < std::chrono::microseconds(0)) + { + // TODO: alert caller of invalid timeout? + return false; + } + // Should only shutdown exporter ONCE. if (!shutdown_latch_.test_and_set(std::memory_order_acquire)) { diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index 02e7c47275..86f250cce2 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -69,12 +69,12 @@ TEST(LoggerProviderSDK, LoggerProviderLoggerArguments) class DummyProcessor : public LogProcessor { - void OnReceive(std::unique_ptr &&record) noexcept {} - bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept + void OnReceive(std::shared_ptr record) noexcept {} + bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept { return true; } - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept + bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept { return true; } diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index d4825d0032..329bb4a935 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -34,44 +34,3 @@ TEST(LoggerSDK, LogToNullProcessor) r.name = "Test log"; logger->log(r); } - -class DummyProcessor : public LogProcessor -{ - void OnReceive(std::unique_ptr &&record) noexcept {} - bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept - { - return true; - } - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept - { - return true; - } -}; - -TEST(LoggerSDK, LogToAProcessor) -{ - // Create an API LoggerProvider and logger - auto api_lp = std::shared_ptr(new LoggerProvider()); - auto logger = api_lp->GetLogger("logger"); - - // Cast the API LoggerProvider to an SDK Logger Provider and assert that it is still the same - // LoggerProvider by checking that getting a logger with the same name as the previously defined - // logger is the same instance - auto lp = static_cast(api_lp.get()); - auto logger2 = lp->GetLogger("logger"); - ASSERT_EQ(logger, logger2); - - // Set a processor for the LoggerProvider - std::shared_ptr processor = std::shared_ptr(new DummyProcessor()); - lp->SetProcessor(processor); - ASSERT_EQ(processor, lp->GetProcessor()); - - // Should later introduce a way to assert that - // the logger's processor is the same as "proc" - // and that the logger's processor is the same as lp's processor - - // Log a sample log record to the processor - opentelemetry::logs::LogRecord r; - r.name = "Test log"; - logger->log(r); -} diff --git a/sdk/test/logs/simple_log_processor_test.cc b/sdk/test/logs/simple_log_processor_test.cc index 80c83183d3..00e40a53b7 100644 --- a/sdk/test/logs/simple_log_processor_test.cc +++ b/sdk/test/logs/simple_log_processor_test.cc @@ -26,7 +26,7 @@ class TestExporter final : public LogExporter // Stores the names of the log records this exporter receives to an internal list ExportResult Export( - const opentelemetry::nostd::span> &records) noexcept override + const opentelemetry::nostd::span> &records) noexcept override { *batch_size_received = records.size(); for (auto &record : records) @@ -116,7 +116,7 @@ class FailShutDownExporter final : public LogExporter FailShutDownExporter() {} ExportResult Export( - const opentelemetry::nostd::span> &records) noexcept override + const opentelemetry::nostd::span> &records) noexcept override { return ExportResult::kSuccess; }