diff --git a/docs/changes/newsfragments/5278.improved b/docs/changes/newsfragments/5278.improved new file mode 100644 index 00000000000..955ad574e47 --- /dev/null +++ b/docs/changes/newsfragments/5278.improved @@ -0,0 +1,3 @@ +Very noisy log messages from `azure.monitor.opentelemetry.exporter` are now +by default filtered and not shown in the console logger. This matches the +behavior of the OpenCensus exporter. diff --git a/qcodes/__init__.py b/qcodes/__init__.py index 24fc70937f7..692dcc960cc 100644 --- a/qcodes/__init__.py +++ b/qcodes/__init__.py @@ -1,6 +1,10 @@ """Set up the main qcodes namespace.""" -# flake8: noqa (we don't need the "<...> imported but unused" error) +# ruff: noqa: F401, E402 +# This module still contains a lot of short hand imports +# since these imports are discouraged and they are officially +# added elsewhere under their respective submodules we cannot add +# them to __all__ here so silence the warning. # config import warnings diff --git a/qcodes/logger/logger.py b/qcodes/logger/logger.py index bcd1abe7180..272b8c71550 100644 --- a/qcodes/logger/logger.py +++ b/qcodes/logger/logger.py @@ -67,15 +67,21 @@ _opencensus_filter = logging.Filter(name="opencensus") _urllib3_connection_filter = logging.Filter(name="urllib3.connection") +_azure_monitor_opentelemetry_exporter_filter = logging.Filter( + name="azure.monitor.opentelemetry.exporter" +) def filter_out_telemetry_log_records(record: logging.LogRecord) -> bool: """ here we filter any message that is likely to be thrown from - opencensus so it is not shown in the user console + opencensus/opentelemetry so it is not shown in the user console """ - return (not _opencensus_filter.filter(record) - and not _urllib3_connection_filter.filter(record)) + return ( + not _opencensus_filter.filter(record) + and not _urllib3_connection_filter.filter(record) + and not _azure_monitor_opentelemetry_exporter_filter + ) def get_formatter() -> logging.Formatter: