Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable
* @param id the event Id to set
* @param name the event name to set
*/
void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override
{
// TODO: export Event Id to OTLP
}
void SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept override;

/**
* Set the trace id for this log.
Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/src/otlp_log_recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ void OtlpLogRecordable::SetBody(const opentelemetry::common::AttributeValue &mes
OtlpPopulateAttributeUtils::PopulateAnyValue(proto_record_.mutable_body(), message);
}

void OtlpLogRecordable::SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept
{
proto_record_.set_event_name(event_name.data(), event_name.size());
}

void OtlpLogRecordable::SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept
{
if (trace_id.IsValid())
Expand Down
10 changes: 10 additions & 0 deletions exporters/otlp/test/otlp_log_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ TEST(OtlpLogRecordable, SetInstrumentationScope)
EXPECT_EQ(&rec.GetInstrumentationScope(), inst_lib.get());
}

TEST(OtlpLogRecordable, SetEventName)
{
OtlpLogRecordable rec;

nostd::string_view event_name = "Test Event";
rec.SetEventId(0, event_name);

EXPECT_EQ(rec.log_record().event_name(), event_name);
}

/**
* AttributeValue can contain different int types, such as int, int64_t,
* unsigned int, and uint64_t. To avoid writing test cases for each, we can
Expand Down
Loading