Skip to content

Commit

Permalink
Rename OnReceive to OnEmit
Browse files Browse the repository at this point in the history
Signed-off-by: owent <admin@owent.net>
  • Loading branch information
owent committed Oct 4, 2022
1 parent 951768a commit 25966bd
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/batch_log_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BatchLogProcessor : public LogProcessor
* @param record the log record
*/

void OnReceive(std::unique_ptr<Recordable> &&record) noexcept override;
void OnEmit(std::unique_ptr<Recordable> &&record) noexcept override;

/**
* Export all log records that have not been exported yet.
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/logs/multi_log_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class MultiLogProcessor : public LogProcessor
std::unique_ptr<Recordable> 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<Recordable> &&record) noexcept override;
void OnEmit(std::unique_ptr<Recordable> &&record) noexcept override;

/**
* Exports all log records that have not yet been exported to the configured Exporter.
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/logs/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class LogProcessor
virtual std::unique_ptr<Recordable> 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<Recordable> &&record) noexcept = 0;
virtual void OnEmit(std::unique_ptr<Recordable> &&record) noexcept = 0;

/**
* Exports all log records that have not yet been exported to the configured Exporter.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/simple_log_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SimpleLogProcessor : public LogProcessor

std::unique_ptr<Recordable> MakeRecordable() noexcept override;

void OnReceive(std::unique_ptr<Recordable> &&record) noexcept override;
void OnEmit(std::unique_ptr<Recordable> &&record) noexcept override;

bool ForceFlush(
std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/logs/batch_log_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ std::unique_ptr<Recordable> BatchLogProcessor::MakeRecordable() noexcept
return exporter_->MakeRecordable();
}

void BatchLogProcessor::OnReceive(std::unique_ptr<Recordable> &&record) noexcept
void BatchLogProcessor::OnEmit(std::unique_ptr<Recordable> &&record) noexcept
{
if (synchronization_data_->is_shutdown.load() == true)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/logs/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/logs/multi_log_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ std::unique_ptr<Recordable> MultiLogProcessor::MakeRecordable() noexcept
return recordable;
}

void MultiLogProcessor::OnReceive(std::unique_ptr<Recordable> &&record) noexcept
void MultiLogProcessor::OnEmit(std::unique_ptr<Recordable> &&record) noexcept
{
if (!record)
{
Expand All @@ -61,7 +61,7 @@ void MultiLogProcessor::OnReceive(std::unique_ptr<Recordable> &&record) noexcept
auto recordable = multi_recordable->ReleaseRecordable(*processor);
if (recordable)
{
processor->OnReceive(std::move(recordable));
processor->OnEmit(std::move(recordable));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/logs/simple_log_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::unique_ptr<Recordable> 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<Recordable> &&record) noexcept
void SimpleLogProcessor::OnEmit(std::unique_ptr<Recordable> &&record) noexcept
{
nostd::span<std::unique_ptr<Recordable>> batch(&record, 1);
// Get lock to ensure Export() is never called concurrently
Expand Down
12 changes: 6 additions & 6 deletions sdk/test/logs/batch_log_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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
Expand Down Expand Up @@ -147,7 +147,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());
Expand All @@ -163,7 +163,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());
Expand Down Expand Up @@ -192,7 +192,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());
Expand All @@ -216,7 +216,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());
Expand Down Expand Up @@ -249,7 +249,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);
Expand Down
4 changes: 3 additions & 1 deletion sdk/test/logs/logger_provider_sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ class DummyProcessor : public LogProcessor
return std::unique_ptr<Recordable>(new LogRecord);
}

void OnReceive(std::unique_ptr<Recordable> &&record) noexcept {}
void OnEmit(std::unique_ptr<Recordable> &&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;
Expand Down
7 changes: 4 additions & 3 deletions sdk/test/logs/logger_sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<logs_api::LoggerProvider>(new LoggerProvider());
const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"};
Expand Down Expand Up @@ -44,9 +44,10 @@ class MockProcessor final : public LogProcessor
{
return std::unique_ptr<Recordable>(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<Recordable> &&record) noexcept
void OnEmit(std::unique_ptr<Recordable> &&record) noexcept
{
// Cast the recordable received into a concrete LogRecord type
auto copy = std::shared_ptr<LogRecord>(static_cast<LogRecord *>(record.release()));
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/logs/simple_log_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 25966bd

Please sign in to comment.