Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo committed Dec 9, 2021
1 parent 3349d14 commit 73d026b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/logger_provider.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LoggerProvider

virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url) = 0;
nostd::string_view schema_url = "") = 0;
};
} // namespace logs
OPENTELEMETRY_END_NAMESPACE
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/logs/noop.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options,
nostd::string_view schema_url) override
nostd::string_view schema_url = "") override
{
return logger_;
}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url) override
nostd::string_view schema_url = "") override
{
return logger_;
}
Expand Down
8 changes: 6 additions & 2 deletions api/test/logs/logger_test.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ class TestLogger : public Logger
// Define a basic LoggerProvider class that returns an instance of the logger class defined above
class TestProvider : public LoggerProvider
{
shared_ptr<Logger> GetLogger(string_view library_name, string_view options = "") override
shared_ptr<Logger> GetLogger(string_view library_name,
string_view options = "",
nostd::string_view schema_url = "") override
{
return shared_ptr<Logger>(new TestLogger());
}

shared_ptr<Logger> GetLogger(string_view library_name, span<string_view> args) override
shared_ptr<Logger> GetLogger(string_view library_name,
span<string_view> args,
nostd::string_view schema_url = "") override
{
return shared_ptr<Logger>(new TestLogger());
}
Expand Down
8 changes: 6 additions & 2 deletions api/test/logs/provider_test.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ using opentelemetry::nostd::string_view;

class TestProvider : public LoggerProvider
{
shared_ptr<Logger> GetLogger(string_view library_name, string_view options) override
shared_ptr<Logger> GetLogger(string_view library_name,
string_view options,
string_view schema_url = "") override
{
return shared_ptr<Logger>(nullptr);
}

shared_ptr<Logger> GetLogger(string_view library_name, span<string_view> args) override
shared_ptr<Logger> GetLogger(string_view library_name,
span<string_view> args,
string_view schema_url = "") override
{
return shared_ptr<Logger>(nullptr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable
* Returns a JSON object contain the log information
*/
nlohmann::json GetJSON() noexcept { return json_; };

void SetInstrumentationLibrary(
std::unique_ptr<sdk::instrumentationlibrary::InstrumentationLibrary>
instrumentation_library) noexcept override
{}
};
} // namespace logs
} // namespace exporter
Expand Down
11 changes: 7 additions & 4 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider
* - "XML" - XML events (reserved for future use)
* @return
*/
nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(nostd::string_view name,
nostd::string_view args = "") override
nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
nostd::string_view name,
nostd::string_view args = "",
nostd::string_view schema_url = "") override
{
UNREFERENCED_PARAMETER(args);
ETWProvider::EventFormat evtFmt = config_.encoding;
Expand All @@ -233,9 +235,10 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider

nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
nostd::string_view name,
nostd::span<nostd::string_view> args) override
nostd::span<nostd::string_view> args,
nostd::string_view schema_url = "") override
{
return GetLogger(name, args[0]);
return GetLogger(name, args[0], schema_url);
}
};

Expand Down
5 changes: 5 additions & 0 deletions sdk/include/opentelemetry/sdk/logs/log_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ class LogRecord final : public Recordable
* @return the timestamp for this log
*/
opentelemetry::common::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; }

void SetInstrumentationLibrary(
std::unique_ptr<sdk::instrumentationlibrary::InstrumentationLibrary>
instrumentation_library) noexcept override
{}
};
} // namespace logs
} // namespace sdk
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/logger_provider.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LoggerProvider final : public opentelemetry::logs::LoggerProvider,
opentelemetry::nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
opentelemetry::nostd::string_view name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url) noexcept override;
nostd::string_view schema_url = "") noexcept override;

/**
* Returns a shared pointer to the processor currently stored in the
Expand Down

0 comments on commit 73d026b

Please sign in to comment.