From 4a66733e17c4dc00fb0255c9564044eecf6f1d91 Mon Sep 17 00:00:00 2001 From: owent Date: Tue, 4 Oct 2022 15:37:06 +0800 Subject: [PATCH] Rename `OnReceive` to `OnEmit` Signed-off-by: owent --- .../opentelemetry/sdk/logs/batch_log_processor.h | 2 +- .../opentelemetry/sdk/logs/multi_log_processor.h | 4 ++-- sdk/include/opentelemetry/sdk/logs/processor.h | 4 ++-- .../opentelemetry/sdk/logs/simple_log_processor.h | 2 +- sdk/src/logs/batch_log_processor.cc | 2 +- sdk/src/logs/logger.cc | 2 +- sdk/src/logs/multi_log_processor.cc | 4 ++-- sdk/src/logs/simple_log_processor.cc | 2 +- sdk/test/logs/batch_log_processor_test.cc | 12 ++++++------ sdk/test/logs/logger_provider_sdk_test.cc | 2 +- sdk/test/logs/logger_sdk_test.cc | 7 ++++--- sdk/test/logs/simple_log_processor_test.cc | 2 +- 12 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h index e70b511a10..e942564e28 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h @@ -64,7 +64,7 @@ class BatchLogProcessor : public LogProcessor * @param record the log record */ - void OnReceive(std::unique_ptr &&record) noexcept override; + void OnEmit(std::unique_ptr &&record) noexcept override; /** * Export all log records that have not been exported yet. diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h b/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h index c1bda24a0b..227e2e020f 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_processor.h @@ -36,10 +36,10 @@ class MultiLogProcessor : public LogProcessor std::unique_ptr MakeRecordable() noexcept override; /** - * OnReceive is called by the SDK once a log record has been successfully created. + * OnEmit is called by the SDK once a log record has been successfully created. * @param record the log record */ - void OnReceive(std::unique_ptr &&record) noexcept override; + void OnEmit(std::unique_ptr &&record) noexcept override; /** * Exports all log records that have not yet been exported to the configured Exporter. diff --git a/sdk/include/opentelemetry/sdk/logs/processor.h b/sdk/include/opentelemetry/sdk/logs/processor.h index 36da036f31..0fdc8a422f 100644 --- a/sdk/include/opentelemetry/sdk/logs/processor.h +++ b/sdk/include/opentelemetry/sdk/logs/processor.h @@ -32,10 +32,10 @@ class LogProcessor virtual std::unique_ptr MakeRecordable() noexcept = 0; /** - * OnReceive is called by the SDK once a log record has been successfully created. + * OnEmit 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 OnEmit(std::unique_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 45f4683973..8364cedd4c 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h @@ -33,7 +33,7 @@ class SimpleLogProcessor : public LogProcessor std::unique_ptr MakeRecordable() noexcept override; - void OnReceive(std::unique_ptr &&record) noexcept override; + void OnEmit(std::unique_ptr &&record) noexcept override; bool ForceFlush( std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; diff --git a/sdk/src/logs/batch_log_processor.cc b/sdk/src/logs/batch_log_processor.cc index ecba6d75bd..35092652cb 100644 --- a/sdk/src/logs/batch_log_processor.cc +++ b/sdk/src/logs/batch_log_processor.cc @@ -53,7 +53,7 @@ std::unique_ptr BatchLogProcessor::MakeRecordable() noexcept return exporter_->MakeRecordable(); } -void BatchLogProcessor::OnReceive(std::unique_ptr &&record) noexcept +void BatchLogProcessor::OnEmit(std::unique_ptr &&record) noexcept { if (synchronization_data_->is_shutdown.load() == true) { diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index f934107fae..d7ab485dff 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -111,7 +111,7 @@ void Logger::Log(opentelemetry::logs::Severity severity, } // Send the log record to the processor - processor.OnReceive(std::move(recordable)); + processor.OnEmit(std::move(recordable)); } const opentelemetry::sdk::instrumentationscope::InstrumentationScope & diff --git a/sdk/src/logs/multi_log_processor.cc b/sdk/src/logs/multi_log_processor.cc index 5c7fe400f9..a6b2eef1f3 100644 --- a/sdk/src/logs/multi_log_processor.cc +++ b/sdk/src/logs/multi_log_processor.cc @@ -48,7 +48,7 @@ std::unique_ptr MultiLogProcessor::MakeRecordable() noexcept return recordable; } -void MultiLogProcessor::OnReceive(std::unique_ptr &&record) noexcept +void MultiLogProcessor::OnEmit(std::unique_ptr &&record) noexcept { if (!record) { @@ -61,7 +61,7 @@ void MultiLogProcessor::OnReceive(std::unique_ptr &&record) noexcept auto recordable = multi_recordable->ReleaseRecordable(*processor); if (recordable) { - processor->OnReceive(std::move(recordable)); + processor->OnEmit(std::move(recordable)); } } } diff --git a/sdk/src/logs/simple_log_processor.cc b/sdk/src/logs/simple_log_processor.cc index f5b82c0bbc..3d5d798c0a 100644 --- a/sdk/src/logs/simple_log_processor.cc +++ b/sdk/src/logs/simple_log_processor.cc @@ -29,7 +29,7 @@ std::unique_ptr SimpleLogProcessor::MakeRecordable() noexcept * 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::OnEmit(std::unique_ptr &&record) noexcept { nostd::span> batch(&record, 1); // Get lock to ensure Export() is never called concurrently diff --git a/sdk/test/logs/batch_log_processor_test.cc b/sdk/test/logs/batch_log_processor_test.cc index 18e3ee531d..b6fb240ee5 100644 --- a/sdk/test/logs/batch_log_processor_test.cc +++ b/sdk/test/logs/batch_log_processor_test.cc @@ -111,7 +111,7 @@ TEST_F(BatchLogProcessorTest, TestShutdown) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } // Test that shutting down the processor will first wait for the @@ -146,7 +146,7 @@ TEST_F(BatchLogProcessorTest, TestForceFlush) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } EXPECT_TRUE(batch_processor->ForceFlush()); @@ -162,7 +162,7 @@ TEST_F(BatchLogProcessorTest, TestForceFlush) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } EXPECT_TRUE(batch_processor->ForceFlush()); @@ -191,7 +191,7 @@ TEST_F(BatchLogProcessorTest, TestManyLogsLoss) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } EXPECT_TRUE(batch_processor->ForceFlush()); @@ -215,7 +215,7 @@ TEST_F(BatchLogProcessorTest, TestManyLogsLossLess) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } EXPECT_TRUE(batch_processor->ForceFlush()); @@ -248,7 +248,7 @@ TEST_F(BatchLogProcessorTest, TestScheduledDelayMillis) { auto log = batch_processor->MakeRecordable(); log->SetBody("Log" + std::to_string(i)); - batch_processor->OnReceive(std::move(log)); + batch_processor->OnEmit(std::move(log)); } // Sleep for scheduled_delay_millis milliseconds std::this_thread::sleep_for(scheduled_delay_millis); diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index 1488798f07..6bf738e812 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -86,7 +86,7 @@ class DummyProcessor : public LogProcessor return std::unique_ptr(new LogRecord); } - void OnReceive(std::unique_ptr && /* record */) noexcept override {} + void OnEmit(std::unique_ptr && /* record */) noexcept override {} bool ForceFlush(std::chrono::microseconds /* timeout */) noexcept override { return true; } bool Shutdown(std::chrono::microseconds /* timeout */) noexcept override { return true; } }; diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index 36278349ba..91279341c6 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -15,7 +15,7 @@ TEST(LoggerSDK, LogToNullProcessor) { // Confirm Logger::Log() does not have undefined behavior // even when there is no processor set - // since it calls Processor::OnReceive() + // since it calls Processor::OnEmit() auto lp = std::shared_ptr(new LoggerProvider()); const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; @@ -44,9 +44,10 @@ class MockProcessor final : public LogProcessor { return std::unique_ptr(new LogRecord); } - // OnReceive stores the record it receives into the shared_ptr recordable passed into its + + // OnEmit stores the record it receives into the shared_ptr recordable passed into its // constructor - void OnReceive(std::unique_ptr &&record) noexcept override + void OnEmit(std::unique_ptr &&record) noexcept override { // Cast the recordable received into a concrete LogRecord type auto copy = std::shared_ptr(static_cast(record.release())); diff --git a/sdk/test/logs/simple_log_processor_test.cc b/sdk/test/logs/simple_log_processor_test.cc index 1e77b2a858..008ca7c522 100644 --- a/sdk/test/logs/simple_log_processor_test.cc +++ b/sdk/test/logs/simple_log_processor_test.cc @@ -86,7 +86,7 @@ TEST(SimpleLogProcessorTest, SendReceivedLogsToExporter) { auto recordable = processor.MakeRecordable(); recordable->SetBody("Log Body"); - processor.OnReceive(std::move(recordable)); + processor.OnEmit(std::move(recordable)); // Verify that the batch of 1 log record sent by processor matches what exporter received EXPECT_EQ(1, batch_size_received);