Skip to content

Initial Commit of Logging SDK#5

Closed
MarkSeufert wants to merge 34 commits into
masterfrom
logs-sdk
Closed

Initial Commit of Logging SDK#5
MarkSeufert wants to merge 34 commits into
masterfrom
logs-sdk

Conversation

@MarkSeufert
Copy link
Copy Markdown

@MarkSeufert MarkSeufert commented Nov 4, 2020

This PR contains an initial implementation of the Logging SDK, which follows from the initial API commit and the logging prototype issue.

This PR adds:

  • SDK LoggerProvider class - returns instances of the SDK Logger and stores a common processor
  • SDK Logger class - filters logs based off severity and sends to a processor
  • Processor Interface - interface that defines what a processor implementation will require. A future PR will contain concrete processor classes derived from this
  • Unit tests for the LoggerProvider and Logger classes

The design doc for the Logging SDK will be released in a future PR.
cc @xukaren @alolita

@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 4, 2020

Codecov Report

Merging #5 (44476db) into master (8c455f7) will decrease coverage by 0.22%.
The diff coverage is 75.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
- Coverage   94.98%   94.76%   -0.23%     
==========================================
  Files         162      169       +7     
  Lines        6996     7082      +86     
==========================================
+ Hits         6645     6711      +66     
- Misses        351      371      +20     
Impacted Files Coverage Δ
sdk/src/logs/logger.cc 52.17% <52.17%> (ø)
sdk/src/logs/logger_provider.cc 70.83% <70.83%> (ø)
sdk/test/logs/logger_provider_sdk_test.cc 89.28% <89.28%> (ø)
sdk/include/opentelemetry/sdk/logs/logger.h 100.00% <100.00%> (ø)
...k/include/opentelemetry/sdk/logs/logger_provider.h 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/logs/processor.h 100.00% <100.00%> (ø)
sdk/test/logs/logger_sdk_test.cc 100.00% <100.00%> (ø)
...de/opentelemetry/exporters/ostream/span_exporter.h 96.29% <0.00%> (ø)
... and 6 more

Copy link
Copy Markdown

@alolita alolita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm #shipit

Copy link
Copy Markdown

@ranton256 ranton256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is signified by the sdk/logs/TBD and sdk/src/logs/TBD empty files.

*/
std::shared_ptr<LogProcessor> GetProcessor() noexcept;

// Sets the common processor that all the Logger instances will use
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the // comment outside the /** comment? Are you excluding this intentionally?

*/
opentelemetry::nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view options = "") noexcept override;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there docs in API or spec or elsewhere for what options argument should support?

opentelemetry::sdk::AtomicSharedPtr<LogProcessor> processor_;

// A vector of pointers to all the loggers that have been created
std::vector<std::shared_ptr<Logger>> loggers_;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing the loggers in a vector will require linear search in O(n) time anytime someone asks for a logger by name. I am not sure if this is okay. It depends on the expected worst case for how many loggers anyone is going to have.

Comment thread sdk/src/logs/logger_provider.cc Outdated
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view options) noexcept
{
// Search if a logger with the given name already exists.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since lookup is probably a more frequent use case than scanning all loggers, and uniqueness by name is important, you should probably use std::unordered_set or maybe map instead of vector for storing the loggers. It's possible if you only ever have very few elements in the vector(like 3 or 4) that. you might win that way, but the performance will be bad for someone with lots. It would also save you having to manage the uniqueness constraint yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants