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

Support logging level config of handler through configure_azure_monitor #36395

Open
yli02 opened this issue Jul 9, 2024 · 7 comments
Open

Support logging level config of handler through configure_azure_monitor #36395

yli02 opened this issue Jul 9, 2024 · 7 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor Monitor, Monitor Ingestion, Monitor Query needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@yli02
Copy link

yli02 commented Jul 9, 2024

Is your feature request related to a problem? Please describe.
The current logging configuration in [1] does not support to set the logging level for handler in [2], and this prevents to separate the logging to Azure and local in different levels based on logger hierarchy. For example

import logging
from azure.monitor.opentelemetry import configure_azure_monitor

app_logger = logging.getLogger("App")
app_logger.setLevel(logging.ERROR)

app_local_logger = logging.getLogger("App.local")
app_local_logger.setLevel(logging.INFO)

configure_azure_monitor(connection_string="", logger_name="app_logger")

In the application, we would like to always use logger "app_logger_local" for different level of loggings to stdout and stderr, and relying on logging hierarchy to pass logs to "app_logger". And we only would like to use Azure AppInsights to collect log with level ERROR or higher.

But this design is so far not feasible, as there is no checking of parent logger level at [3], see also [4].

Describe the solution you'd like
It would be great if a new argument could be added to [1], like logging_level to setup the logging level of the handler in [2], so we could rely on the above example code to collect loggings in different levels at different destination.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
[1]

def configure_azure_monitor(**kwargs) -> None: # pylint: disable=C4758

[2]

handler = LoggingHandler(logger_provider=logger_provider)

[3] https://github.com/python/cpython/blob/15d48aea02099ffc5bdc5511cc53ced460cb31b9/Lib/logging/__init__.py#L1715

[4] python/cpython#75045 (comment)

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 9, 2024
@xiangyan99 xiangyan99 removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jul 9, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jul 9, 2024
@xiangyan99 xiangyan99 added Monitor Monitor, Monitor Ingestion, Monitor Query Service Attention Workflow: This issue is responsible by Azure service team. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jul 9, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jul 9, 2024
Copy link

github-actions bot commented Jul 9, 2024

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @gracewilcox @gulopesd @Haiying-MSFT @jairmyree @joshfree @KarishmaGhiya @KevinBlasko @kurtzeborn @nisha-bhatia @pvaneck @sarangan12 @scottaddie @srnagar @ToddKingMSFT.

@lzchen
Copy link
Member

lzchen commented Jul 10, 2024

@yli02

This scenario makes sense. A solution via environment variable in upstream OpenTelemetry Python would be able to enable this scenario and allow you to configure log level of the OpenTelemetry LoggingHandler. This however has not been implemented yet.

As a side note, you must also change your code to pass in the namespace of the parent logger you want to use, not the variable name of the logger.

...
app_logger = logging.getLogger("App")
configure_azure_monitor(connection_string="", logger_name="App")
...

@xiangyan99 xiangyan99 added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Sep 6, 2024
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 6, 2024
Copy link

github-actions bot commented Sep 6, 2024

Hi @yli02. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

Copy link

Hi @yli02, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label Sep 13, 2024
@yli02
Copy link
Author

yli02 commented Sep 19, 2024

Hi, sorry for the delay in replying, I was actually not sure what other actions I should perform if this is a valid request but could not be supported at the moment.

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. labels Sep 19, 2024
@lzchen
Copy link
Member

lzchen commented Sep 19, 2024

@yli02

This issue would have to be implemented for this feature to be enabled.

@yli02
Copy link
Author

yli02 commented Sep 19, 2024

@lzchen thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor Monitor, Monitor Ingestion, Monitor Query needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants