File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import logging
2+ import os
23import time
34import warnings
45from collections import defaultdict
2223)
2324from tqdm .auto import tqdm
2425
26+ from datareservoirio ._constants import ENV_VAR_ENABLE_APP_INSIGHTS
27+
2528from ._logging import log_decorator
2629from ._utils import function_translation , period_translation
2730from .globalsettings import environment
3336@cache
3437def metric () -> logging .Logger :
3538 logger = logging .getLogger (__name__ + "_metric_appinsight" )
36- logger .setLevel (logging .DEBUG )
37- configure_azure_monitor (
38- connection_string = environment ._application_insight_connectionstring ,
39- logger_name = __name__ + "_metric_appinsight" ,
40- )
39+ if os .getenv (ENV_VAR_ENABLE_APP_INSIGHTS ) is not None :
40+ enable_app_insights = os .environ [ENV_VAR_ENABLE_APP_INSIGHTS ].lower ()
41+ if enable_app_insights == "true" or enable_app_insights == "1" :
42+ logger .setLevel (logging .DEBUG )
43+ configure_azure_monitor (
44+ connection_string = environment ._application_insight_connectionstring ,
45+ logger_name = __name__ + "_metric_appinsight" ,
46+ )
4147 return logger
4248
4349
Original file line number Diff line number Diff line change 1- import logging
21from io import BytesIO
32from pathlib import Path
43from unittest .mock import Mock
1312TEST_PATH = Path (__file__ ).parent
1413
1514
16- @pytest .fixture (autouse = True )
17- def disable_logging (monkeypatch ):
18- """Disable logging to Application Insight"""
19-
20-
21- # monkeypatch.setattr("datareservoirio.client.AzureLogHandler", logging.NullHandler())
22-
23-
2415@pytest .fixture
2516def response_cases ():
2617 class ResponseCaseHandler :
You can’t perform that action at this time.
0 commit comments