Skip to content

Commit

Permalink
Merge branch 'main' into add-meter-scope-config
Browse files Browse the repository at this point in the history
  • Loading branch information
psx95 authored Feb 19, 2025
2 parents 3b648bb + 821ad9e commit 60db25b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/fossa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: FOSSA scanning

on:
push:
branches:
- main

permissions:
contents: read

jobs:
fossa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: fossas/fossa-action@93a52ecf7c3ac7eb40f5de77fd69b1a19524de94 # v1.5.0
with:
api-key: ${{secrets.FOSSA_API_KEY}}
team: OpenTelemetry
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
4 changes: 4 additions & 0 deletions sdk/src/metrics/instrument_metadata_validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@

#if OPENTELEMETRY_HAVE_WORKING_REGEX
# include <regex>
#else
# include <algorithm>
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace metrics
{
#if OPENTELEMETRY_HAVE_WORKING_REGEX
// instrument-name = ALPHA 0*254 ("_" / "." / "-" / "/" / ALPHA / DIGIT)
const std::string kInstrumentNamePattern = "[a-zA-Z][-_./a-zA-Z0-9]{0,254}";
//
const std::string kInstrumentUnitPattern = "[\x01-\x7F]{0,63}";
// instrument-unit = It can have a maximum length of 63 ASCII chars
#endif

InstrumentMetaDataValidator::InstrumentMetaDataValidator()
#if OPENTELEMETRY_HAVE_WORKING_REGEX
Expand Down

0 comments on commit 60db25b

Please sign in to comment.