Skip to content

Commit d7997c0

Browse files
Merge branch 'main' into main
2 parents 77b88a2 + 7f047d5 commit d7997c0

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable
7676
* @param id the event Id to set
7777
* @param name the event name to set
7878
*/
79-
void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override
80-
{
81-
// TODO: export Event Id to OTLP
82-
}
79+
void SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept override;
8380

8481
/**
8582
* Set the trace id for this log.

exporters/otlp/src/otlp_log_recordable.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ void OtlpLogRecordable::SetBody(const opentelemetry::common::AttributeValue &mes
197197
OtlpPopulateAttributeUtils::PopulateAnyValue(proto_record_.mutable_body(), message);
198198
}
199199

200+
void OtlpLogRecordable::SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept
201+
{
202+
proto_record_.set_event_name(event_name.data(), event_name.size());
203+
}
204+
200205
void OtlpLogRecordable::SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept
201206
{
202207
if (trace_id.IsValid())

exporters/otlp/test/otlp_log_recordable_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ TEST(OtlpLogRecordable, SetInstrumentationScope)
174174
EXPECT_EQ(&rec.GetInstrumentationScope(), inst_lib.get());
175175
}
176176

177+
TEST(OtlpLogRecordable, SetEventName)
178+
{
179+
OtlpLogRecordable rec;
180+
181+
nostd::string_view event_name = "Test Event";
182+
rec.SetEventId(0, event_name);
183+
184+
EXPECT_EQ(rec.log_record().event_name(), event_name);
185+
}
186+
177187
/**
178188
* AttributeValue can contain different int types, such as int, int64_t,
179189
* unsigned int, and uint64_t. To avoid writing test cases for each, we can

sdk/src/metrics/instrument_metadata_validator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99

1010
#if OPENTELEMETRY_HAVE_WORKING_REGEX
1111
# include <regex>
12+
#else
13+
# include <algorithm>
1214
#endif
1315

1416
OPENTELEMETRY_BEGIN_NAMESPACE
1517
namespace sdk
1618
{
1719
namespace metrics
1820
{
21+
#if OPENTELEMETRY_HAVE_WORKING_REGEX
1922
// instrument-name = ALPHA 0*254 ("_" / "." / "-" / "/" / ALPHA / DIGIT)
2023
const std::string kInstrumentNamePattern = "[a-zA-Z][-_./a-zA-Z0-9]{0,254}";
2124
//
2225
const std::string kInstrumentUnitPattern = "[\x01-\x7F]{0,63}";
2326
// instrument-unit = It can have a maximum length of 63 ASCII chars
27+
#endif
2428

2529
InstrumentMetaDataValidator::InstrumentMetaDataValidator()
2630
#if OPENTELEMETRY_HAVE_WORKING_REGEX

0 commit comments

Comments
 (0)