open-telemetry / open-telemetry/opentelemetry-cpp

Support Dynamically Changing Log Level During Runtime

Open
#3,647 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Stale triage/accepted
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

Problem Statement
Our app supports changing the logging level dynamically at runtime (without requiring a restart). We want to extend this functionality to also dynamically set the SDK's log level without needing to re-create any Providers. However, this functionality is not supported based on the comments in global_log_handler.h.

Describe the solution you'd like
When our app calls GlobalLogHandler::SetLogLevel, we would like the SDK to change it's logging level without needing to recreate and Providers.

Describe alternatives you've considered
We considered recreating providers when the log level changes but do not want to have the overhead of doing that in a large, multi-threaded application. We also tried changing the log level by calling GlobalLogHandler::SetLogLevel but found that changing from Debug to Info works (the debug messages no longer appear), but changing from Info to Debug only partially works (debug messages for "OTLP TRACE HTTP Exporter" appear but debug messages for "OTLP HTTP Client" do not appear).

Additional context
Add any other context about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sdk/include/opentelemetry/sdk/common/global_log_handler.h, especially the comments around SetLogLevel and the existing runtime behavior described for the OTLP TRACE HTTP Exporter and OTLP HTTP Client. Reproduce changing the level from Debug to Info and back without recreating Providers. Done means the SDK consistently applies both transitions to its logging without provider recreation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.