Skip to content

Commit fe8bbb5

Browse files
committed
Do not export if PrepareExport returns false
1 parent 83733d6 commit fe8bbb5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

exporters/user_events/src/logs_exporter.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ sdk::common::ExportResult Exporter::Export(
5252
auto user_events_record =
5353
std::unique_ptr<Recordable>(static_cast<Recordable *>(record.release()));
5454

55-
user_events_record->PrepareExport();
56-
57-
// assert(user_events_record != nullptr, "Recordable is null");
55+
if (!user_events_record->PrepareExport())
56+
{
57+
continue;
58+
}
5859

5960
int level_index = user_events_record->GetLevelIndex();
6061

exporters/user_events/src/recordable.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ void Recordable::SetTimestamp(opentelemetry::common::SystemTimestamp timestamp)
104104

105105
bool Recordable::PrepareExport() noexcept
106106
{
107-
if (cs_part_b_bookmark_size_ > 0)
107+
if (cs_part_b_bookmark_size_ == 0)
108+
{
109+
// Part B is mandatory for exporting to user_events.
110+
OTEL_INTERNAL_LOG_ERROR("[user_events Log Exporter] Recordable: no data to export.");
111+
return false;
112+
}
113+
else
108114
{
109115
event_builder_.SetStructFieldCount(cs_part_b_bookmark_, cs_part_b_bookmark_size_);
110116
}
117+
111118
if (cs_part_c_bookmark_size_ > 0)
112119
{
113120
event_builder_.SetStructFieldCount(cs_part_c_bookmark_, cs_part_c_bookmark_size_);

0 commit comments

Comments
 (0)