Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable log level - native code and loader #2288

Merged

Conversation

lachmatt
Copy link
Contributor

@lachmatt lachmatt commented Mar 6, 2023

Why

Towards #2183
Fixes #372

What

Handle configured OTEL_LOG_LEVEL in native code and loader.

  • Use common logger in loader
  • Set sink's log level in native code based on configured OTEL_LOG_LEVEL value, or use null_sink if none is configured
    - Removed benchmarks of removed LoaderLogger (update: split into Drop LoaderLogger benchmarks #2289 )

Tests

Checklist

  • CHANGELOG.md is updated.
  • Documentation is updated.
    - [ ] New features are covered by tests.

@lachmatt lachmatt requested a review from a team March 6, 2023 09:51
@github-actions github-actions bot requested a review from theletterf March 6, 2023 09:51
@lachmatt lachmatt marked this pull request as draft March 6, 2023 10:23
{
m_fileout = spdlog::rotating_logger_mt("Logger", GetLogPath(file_name_suffix), 1048576 * 5, 10);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make size configurable with OTEL_DOTNET_AUTO_LOG_FILE_SIZE in a separate PR.

// By writing into the stderr was changing the behavior in a CI scenario.
// There's not a good way to report errors when trying to create the log file.
// But we never should be changing the normal behavior of an app.
// std::cerr << "LoggerImpl Handler: Error creating native log file." << std::endl;
m_fileout = spdlog::null_logger_mt("LoggerImpl");
Copy link
Contributor Author

@lachmatt lachmatt Mar 6, 2023

Choose a reason for hiding this comment

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

Filtering out in sink yields simpler implementation (compared to tracking if logLevel is enabled in LoggerImpl before forwarding to sinks), but results in overhead of LogToString conversion which might not be needed. Let me know if I should address that in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favor of adding it in a separate PR: it is typical for log systems to avoid extra work depending on the log level. That's why the log levels are usually treated as comparable integers.

@lachmatt lachmatt marked this pull request as ready for review March 6, 2023 10:53
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@lachmatt lachmatt force-pushed the configurable-log-level-in-native branch from 76621d9 to 8a2f5f3 Compare March 7, 2023 10:20
@pjanotti pjanotti merged commit 61df3cb into open-telemetry:main Mar 7, 2023
@lachmatt lachmatt deleted the configurable-log-level-in-native branch March 7, 2023 18:15
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.

Add OTEL_LOG_LEVEL support
4 participants