Skip to content

Commit 2eb01ac

Browse files
committed
Fix format errors
1 parent db6d69a commit 2eb01ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+495
-292
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_configuration/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _notify_callbacks(self, settings: Dict[str, str]):
8181
try:
8282
cb(settings)
8383
except Exception as ex: # pylint: disable=broad-except
84-
logger.warning("Callback failed: %s", ex) # pylint: disable=do-not-log-exceptions-if-not-debug
84+
logger.warning("Callback failed: %s", ex) # pylint: disable=do-not-log-exceptions-if-not-debug
8585

8686
def _is_transient_error(self, response: OneSettingsResponse) -> bool:
8787
"""Check if the response indicates a transient error.

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_configuration/_utils.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77

88
# mypy: disable-error-code="import-untyped"
9-
import requests # pylint: disable=networking-import-outside-azure-core-transport
9+
import requests # pylint: disable=networking-import-outside-azure-core-transport
1010

1111
from azure.monitor.opentelemetry.exporter._constants import (
1212
_ONE_SETTINGS_DEFAULT_REFRESH_INTERVAL_SECONDS,
@@ -124,16 +124,24 @@ def make_onesettings_request(
124124

125125
return _parse_onesettings_response(result)
126126
except requests.exceptions.Timeout as ex:
127-
logger.warning("OneSettings request timed out: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
127+
logger.warning(
128+
"OneSettings request timed out: %s", str(ex)
129+
) # pylint: disable=do-not-log-exceptions-if-not-debug
128130
return OneSettingsResponse(has_exception=True)
129131
except requests.exceptions.RequestException as ex:
130-
logger.warning("Failed to fetch configuration from OneSettings: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
132+
logger.warning(
133+
"Failed to fetch configuration from OneSettings: %s", str(ex)
134+
) # pylint: disable=do-not-log-exceptions-if-not-debug
131135
return OneSettingsResponse(has_exception=True)
132136
except json.JSONDecodeError as ex:
133-
logger.warning("Failed to parse OneSettings response: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
137+
logger.warning(
138+
"Failed to parse OneSettings response: %s", str(ex)
139+
) # pylint: disable=do-not-log-exceptions-if-not-debug
134140
return OneSettingsResponse(has_exception=True)
135141
except Exception as ex: # pylint: disable=broad-exception-caught
136-
logger.warning("Unexpected error while fetching configuration: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
142+
logger.warning(
143+
"Unexpected error while fetching configuration: %s", str(ex)
144+
) # pylint: disable=do-not-log-exceptions-if-not-debug
137145
return OneSettingsResponse(has_exception=True)
138146

139147

@@ -197,9 +205,13 @@ def _parse_onesettings_response(response: requests.Response) -> OneSettingsRespo
197205
if settings and settings.get(_ONE_SETTINGS_CHANGE_VERSION_KEY) is not None:
198206
version = int(settings.get(_ONE_SETTINGS_CHANGE_VERSION_KEY)) # type: ignore
199207
except (UnicodeDecodeError, json.JSONDecodeError) as ex:
200-
logger.warning("Failed to decode OneSettings response content: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
208+
logger.warning(
209+
"Failed to decode OneSettings response content: %s", str(ex)
210+
) # pylint: disable=do-not-log-exceptions-if-not-debug
201211
except ValueError as ex:
202-
logger.warning("Failed to parse OneSettings change version: %s", str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
212+
logger.warning(
213+
"Failed to parse OneSettings change version: %s", str(ex)
214+
) # pylint: disable=do-not-log-exceptions-if-not-debug
203215
elif status_code == 400:
204216
logger.warning("Bad request to OneSettings: %s", response.content)
205217
elif status_code == 404:

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_configuration/_worker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def _get_configuration(self) -> None:
141141
# Capture interval while we have the lock
142142
interval = self._refresh_interval
143143
except Exception as ex: # pylint: disable=broad-exception-caught
144-
logger.warning("Configuration refresh failed: %s", ex) # pylint: disable=do-not-log-exceptions-if-not-debug
144+
logger.warning(
145+
"Configuration refresh failed: %s", ex
146+
) # pylint: disable=do-not-log-exceptions-if-not-debug
145147
# Use current interval on error
146148
interval = self.get_refresh_interval()
147149

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_performance_counters/_manager.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _get_process_cpu(options: CallbackOptions) -> Iterable[Observation]:
7979
cpu_percent = _PROCESS.cpu_percent(interval=None)
8080
yield Observation(cpu_percent, {})
8181
except (psutil.NoSuchProcess, psutil.AccessDenied, Exception) as e: # pylint: disable=broad-except
82-
_logger.exception("Error getting process CPU usage: %s", e) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
82+
_logger.exception(
83+
"Error getting process CPU usage: %s", e
84+
) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
8385
yield Observation(0.0, {})
8486

8587

@@ -110,7 +112,9 @@ def _get_process_cpu_normalized(options: CallbackOptions) -> Iterable[Observatio
110112

111113
yield Observation(normalized_cpu_percent, {})
112114
except (psutil.NoSuchProcess, psutil.AccessDenied, Exception) as e: # pylint: disable=broad-except
113-
_logger.exception("Error getting normalized process CPU usage: %s", e) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
115+
_logger.exception(
116+
"Error getting normalized process CPU usage: %s", e
117+
) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
114118
yield Observation(0.0, {})
115119

116120

@@ -131,7 +135,9 @@ def _get_available_memory(options: CallbackOptions) -> Iterable[Observation]:
131135
available_memory = psutil.virtual_memory().available
132136
yield Observation(available_memory, {})
133137
except Exception as e: # pylint: disable=broad-except
134-
_logger.exception("Error getting available memory: %s", e) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
138+
_logger.exception(
139+
"Error getting available memory: %s", e
140+
) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
135141
yield Observation(0, {})
136142

137143

@@ -152,7 +158,9 @@ def _get_process_memory(options: CallbackOptions) -> Iterable[Observation]:
152158
private_bytes = _PROCESS.memory_info().rss
153159
yield Observation(private_bytes, {})
154160
except (psutil.NoSuchProcess, psutil.AccessDenied, Exception) as e: # pylint: disable=broad-except
155-
_logger.exception("Error getting process memory: %s", e) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
161+
_logger.exception(
162+
"Error getting process memory: %s", e
163+
) # pylint: disable=logging-not-lazy, do-not-use-logging-exception
156164
yield Observation(0, {})
157165

158166

@@ -245,7 +253,7 @@ def _get_processor_time(options: CallbackOptions) -> Iterable[Observation]:
245253
_LAST_CPU_TIMES = cpu_times
246254
yield Observation(utilization_percentage, {})
247255
except Exception as e: # pylint: disable=broad-except
248-
_logger.exception("Error getting processor time: %s", e) # pylint: disable=do-not-use-logging-exception
256+
_logger.exception("Error getting processor time: %s", e) # pylint: disable=do-not-use-logging-exception
249257
yield Observation(0.0, {})
250258

251259

@@ -603,10 +611,14 @@ def __init__(self, meter_provider=None):
603611
if metric_class == RequestExecutionTime:
604612
self._request_duration_histogram = performance_counter.gauge
605613
except Exception as e: # pylint: disable=broad-except
606-
_logger.warning("Failed to initialize performance counter %s: %s", metric_class.NAME[0], e) # pylint: disable=do-not-log-exceptions-if-not-debug
614+
_logger.warning(
615+
"Failed to initialize performance counter %s: %s", metric_class.NAME[0], e
616+
) # pylint: disable=do-not-log-exceptions-if-not-debug
607617

608618
except Exception as e: # pylint: disable=broad-except
609-
_logger.warning("Failed to setup performance counters: %s", e) # pylint: disable=do-not-log-exceptions-if-not-debug
619+
_logger.warning(
620+
"Failed to setup performance counters: %s", e
621+
) # pylint: disable=do-not-log-exceptions-if-not-debug
610622

611623
def _record_span(self, span: ReadableSpan) -> None:
612624
try:

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ def _do_initialize(self) -> bool:
202202
return True
203203

204204
except Exception as e: # pylint: disable=broad-except
205-
_logger.warning("Failed to initialize QuickpulseManager: %s", e) # pylint: disable=do-not-log-exceptions-if-not-debug
205+
_logger.warning(
206+
"Failed to initialize QuickpulseManager: %s", e
207+
) # pylint: disable=do-not-log-exceptions-if-not-debug
206208
# Ensure cleanup happens and state is consistent
207209
self._cleanup()
208210
return False

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ def __init__(self, **kwargs: Any) -> None:
200200

201201
collect_statsbeat_metrics(self)
202202
except Exception as e: # pylint: disable=broad-except
203-
logger.warning("Failed to initialize statsbeat metrics: %s", e) # pylint: disable=do-not-log-exceptions-if-not-debug
203+
logger.warning(
204+
"Failed to initialize statsbeat metrics: %s", e
205+
) # pylint: disable=do-not-log-exceptions-if-not-debug
204206

205207
# customer sdkstats initialization
206208
if self._should_collect_customer_sdkstats():
@@ -439,12 +441,12 @@ def _transmit(self, envelopes: List[TelemetryItem]) -> ExportResult:
439441

440442
if self._should_collect_stats():
441443
exc_type = request_error.exc_type
442-
if exc_type is None or exc_type is type(None): # pylint: disable=unidiomatic-typecheck
444+
if exc_type is None or exc_type is type(None): # pylint: disable=unidiomatic-typecheck
443445
exc_type = request_error.__class__.__name__ # type: ignore
444446
_update_requests_map(_REQ_EXCEPTION_NAME[1], value=exc_type)
445447
result = ExportResult.FAILED_RETRYABLE
446448
except Exception as ex:
447-
logger.exception( # pylint: disable=do-not-use-logging-exception
449+
logger.exception( # pylint: disable=do-not-use-logging-exception
448450
"Envelopes could not be exported and are not retryable: %s.", ex
449451
)
450452

@@ -612,11 +614,11 @@ def _get_authentication_credential(**kwargs: Any) -> Optional[ManagedIdentityCre
612614
credential = ManagedIdentityCredential()
613615
return credential
614616
except ValueError as exc:
615-
logger.error( # pylint: disable=do-not-log-exceptions-if-not-debug
617+
logger.error( # pylint: disable=do-not-log-exceptions-if-not-debug
616618
"APPLICATIONINSIGHTS_AUTHENTICATION_STRING, %s, has invalid format: %s", auth_string, exc
617619
)
618620
except Exception as e:
619-
logger.error( # pylint: disable=do-not-log-exceptions-if-not-debug
621+
logger.error( # pylint: disable=do-not-log-exceptions-if-not-debug
620622
"Failed to get authentication credential and enable AAD: %s", e
621623
)
622624
return None

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_manager.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ def _do_initialize(self, config: StatsbeatConfig) -> bool:
251251

252252
except Exception as e: # pylint: disable=broad-except
253253
# Log the error for debugging
254-
logger.warning("Failed to initialize statsbeat: %s", e) # pylint: disable=do-not-log-exceptions-if-not-debug
254+
logger.warning(
255+
"Failed to initialize statsbeat: %s", e
256+
) # pylint: disable=do-not-log-exceptions-if-not-debug
255257
# Clean up on failure
256258
self._cleanup()
257259
return False
@@ -297,12 +299,16 @@ def _reconfigure(self, new_config: StatsbeatConfig) -> bool:
297299
# Force flush before shutdown to ensure data is sent
298300
self._meter_provider.force_flush(timeout_millis=5000)
299301
except Exception as e: # pylint: disable=broad-except
300-
logger.warning("Failed to flush meter provider during reconfiguration: %s", e) # pylint:disable=do-not-log-exceptions-if-not-debug
302+
logger.warning(
303+
"Failed to flush meter provider during reconfiguration: %s", e
304+
) # pylint:disable=do-not-log-exceptions-if-not-debug
301305

302306
try:
303307
self._meter_provider.shutdown(timeout_millis=5000)
304308
except Exception as e: # pylint: disable=broad-except
305-
logger.warning("Failed to shutdown meter provider during reconfiguration: %s", e) # pylint:disable=do-not-log-exceptions-if-not-debug
309+
logger.warning(
310+
"Failed to shutdown meter provider during reconfiguration: %s", e
311+
) # pylint:disable=do-not-log-exceptions-if-not-debug
306312

307313
# Reset state but keep initialized=True
308314
self._meter_provider = None

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,12 @@ def _get_connection_string_for_region_from_config(target_region: str, settings:
156156
return None
157157
return default_connection_string
158158
except (ValueError, TypeError, KeyError) as ex:
159-
logger.warning("Error parsing configuration for region '%s': %s", target_region, str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
159+
logger.warning(
160+
"Error parsing configuration for region '%s': %s", target_region, str(ex)
161+
) # pylint: disable=do-not-log-exceptions-if-not-debug
160162
return None
161163
except Exception as ex: # pylint: disable=broad-exception-caught
162-
logger.warning("Unexpected error getting stats connection string for region '%s': %s", target_region, str(ex)) # pylint: disable=do-not-log-exceptions-if-not-debug
164+
logger.warning(
165+
"Unexpected error getting stats connection string for region '%s': %s", target_region, str(ex)
166+
) # pylint: disable=do-not-log-exceptions-if-not-debug
163167
return None

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/customer/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional, List, Tuple, Union, Any
55

66
# mypy: disable-error-code="import-untyped"
7-
from requests import ReadTimeout, Timeout # pylint: disable=networking-import-outside-azure-core-transport
7+
from requests import ReadTimeout, Timeout # pylint: disable=networking-import-outside-azure-core-transport
88
from azure.core.exceptions import ServiceRequestTimeoutError
99
from azure.monitor.opentelemetry.exporter._constants import (
1010
_REQUEST,

sdk/monitor/azure-monitor-opentelemetry-exporter/samples/logs/sample_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
val = 1 / 0
3636
print(val)
3737
except ZeroDivisionError:
38-
logger.exception("Error: Division by zero") # pylint: disable=do-not-use-logging-exception
38+
logger.exception("Error: Division by zero") # pylint: disable=do-not-use-logging-exception
3939

4040
try:
4141
val = 1 / 0

0 commit comments

Comments
 (0)