Skip to content

Commit 69aec8d

Browse files
committed
Fix pylint in the distro
1 parent 5cc94e8 commit 69aec8d

13 files changed

Lines changed: 247 additions & 18 deletions

File tree

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
```py
2+
namespace azure.monitor.opentelemetry.exporter
3+
4+
class azure.monitor.opentelemetry.exporter.ApplicationInsightsSampler(Sampler):
5+
6+
def __init__(self, sampling_ratio: float = 1.0): ...
7+
8+
def get_description(self) -> str: ...
9+
10+
def should_sample(
11+
self,
12+
parent_context: Optional[Context],
13+
trace_id: int,
14+
name: str,
15+
kind: Optional[SpanKind] = None,
16+
attributes: Attributes = None,
17+
links: Optional[Sequence[Link]] = None,
18+
trace_state: Optional[TraceState] = None
19+
) -> SamplingResult: ...
20+
21+
22+
class azure.monitor.opentelemetry.exporter.AzureMonitorLogExporter(BaseExporter, LogRecordExporter):
23+
24+
def __init__(
25+
self,
26+
*,
27+
api_version: Optional[str] = ...,
28+
connection_string: Optional[str] = ...,
29+
credential: Optional[ManagedIdentityCredential/ClientSecretCredential] = ...,
30+
disable_offline_storage: Optional[bool] = ...,
31+
max_envelopes_per_second: Optional[int] = ...,
32+
storage_directory: Optional[str] = ...,
33+
**kwargs: Any
34+
) -> None: ...
35+
36+
@classmethod
37+
def from_connection_string(
38+
cls,
39+
conn_str: str,
40+
*,
41+
api_version: Optional[str] = ...,
42+
**kwargs: Any
43+
) -> AzureMonitorLogExporter: ...
44+
45+
def export(
46+
self,
47+
batch: Sequence[ReadableLogRecord],
48+
**kwargs: Any
49+
) -> LogRecordExportResult: ...
50+
51+
def shutdown(self) -> None: ...
52+
53+
54+
class azure.monitor.opentelemetry.exporter.AzureMonitorMetricExporter(BaseExporter, MetricExporter):
55+
56+
def __init__(self, **kwargs: Any) -> None: ...
57+
58+
@classmethod
59+
def from_connection_string(
60+
cls,
61+
conn_str: str,
62+
*,
63+
api_version: Optional[str] = ...,
64+
**kwargs: Any
65+
) -> AzureMonitorMetricExporter: ...
66+
67+
def export(
68+
self,
69+
metrics_data: OTMetricsData,
70+
timeout_millis: float = 10000,
71+
**kwargs: Any
72+
) -> MetricExportResult: ...
73+
74+
def force_flush(self, timeout_millis: float = 10000) -> bool: ...
75+
76+
def shutdown(
77+
self,
78+
timeout_millis: float = 30000,
79+
**kwargs: Any
80+
) -> None: ...
81+
82+
83+
class azure.monitor.opentelemetry.exporter.AzureMonitorTraceExporter(BaseExporter, SpanExporter):
84+
85+
def __init__(self, **kwargs: Any): ...
86+
87+
@classmethod
88+
def from_connection_string(
89+
cls,
90+
conn_str: str,
91+
*,
92+
api_version: Optional[str] = ...,
93+
**kwargs: Any
94+
) -> AzureMonitorTraceExporter: ...
95+
96+
def export(
97+
self,
98+
spans: Sequence[ReadableSpan],
99+
**_kwargs: Any
100+
) -> SpanExportResult: ...
101+
102+
def shutdown(self) -> None: ...
103+
104+
105+
class azure.monitor.opentelemetry.exporter.RateLimitedSampler(Sampler):
106+
107+
def __init__(self, target_spans_per_second_limit: float): ...
108+
109+
def get_description(self) -> str: ...
110+
111+
def should_sample(
112+
self,
113+
parent_context: Optional[Context],
114+
trace_id: int,
115+
name: str,
116+
kind: Optional[SpanKind] = None,
117+
attributes: Attributes = None,
118+
links: Optional[Sequence[Link]] = None,
119+
trace_state: Optional[TraceState] = None
120+
) -> SamplingResult: ...
121+
122+
123+
namespace azure.monitor.opentelemetry.exporter.statsbeat
124+
125+
def azure.monitor.opentelemetry.exporter.statsbeat.collect_statsbeat_metrics(exporter: BaseExporter) -> None: ...
126+
127+
128+
def azure.monitor.opentelemetry.exporter.statsbeat.shutdown_statsbeat_metrics() -> bool: ...
129+
130+
131+
class azure.monitor.opentelemetry.exporter.statsbeat.StatsbeatConfig:
132+
133+
def __eq__(self, other: object) -> bool: ...
134+
135+
def __hash__(self) -> int: ...
136+
137+
def __init__(
138+
self,
139+
endpoint: str,
140+
region: str,
141+
instrumentation_key: str,
142+
disable_offline_storage: bool = False,
143+
credential: Optional[Any] = None,
144+
distro_version: Optional[str] = None,
145+
connection_string: Optional[str] = None
146+
) -> None: ...
147+
148+
@classmethod
149+
def from_config(
150+
cls,
151+
base_config: StatsbeatConfig,
152+
config_dict: Dict[str, str]
153+
) -> Optional[StatsbeatConfig]: ...
154+
155+
@classmethod
156+
def from_exporter(cls, exporter: Any) -> Optional[StatsbeatConfig]: ...
157+
158+
159+
class azure.monitor.opentelemetry.exporter.statsbeat.StatsbeatManager(metaclass=Singleton):
160+
161+
def __init__(self) -> None: ...
162+
163+
def get_current_config(self) -> Optional[StatsbeatConfig]: ...
164+
165+
def initialize(self, config: StatsbeatConfig) -> bool: ...
166+
167+
def is_initialized(self) -> bool: ...
168+
169+
def shutdown(self) -> bool: ...
170+
171+
172+
namespace azure.monitor.opentelemetry.exporter.statsbeat.customer
173+
174+
def azure.monitor.opentelemetry.exporter.statsbeat.customer.collect_customer_sdkstats(exporter: BaseExporter) -> None: ...
175+
176+
177+
def azure.monitor.opentelemetry.exporter.statsbeat.customer.get_customer_stats_manager() -> CustomerSdkStatsManager: ...
178+
179+
180+
def azure.monitor.opentelemetry.exporter.statsbeat.customer.shutdown_customer_sdkstats_metrics() -> None: ...
181+
182+
183+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
apiMdSha256: 4e626c08830ccebb3dab6dab00472543831b70bae5cd17f3bf1432d938991f5b
2+
parserVersion: 0.3.28
3+
pythonVersion: 3.13.14
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```py
2+
namespace azure.monitor.opentelemetry
3+
4+
def azure.monitor.opentelemetry.configure_azure_monitor(
5+
*,
6+
browser_sdk_loader_config: Optional[dict] = ...,
7+
connection_string: Optional[str] = ...,
8+
credential: Union[TokenCredential, None] = ...,
9+
disable_offline_storage: Optional[bool] = ...,
10+
enable_live_metrics: Optional[bool] = ...,
11+
enable_performance_counters: Optional[bool] = ...,
12+
enable_trace_based_sampling_for_logs: Optional[bool] = ...,
13+
instrumentation_options: Optional[dict] = ...,
14+
log_record_processors: Optional[list[LogRecordProcessor]] = ...,
15+
logger_name: Optional[str] = ...,
16+
metric_readers: Optional[list[MetricReader]] = ...,
17+
resource: Optional[Resource] = ...,
18+
span_processors: Optional[list[SpanProcessor]] = ...,
19+
storage_directory: Optional[str] = ...,
20+
views: Optional[list[View]] = ...,
21+
**kwargs
22+
) -> None: ...
23+
24+
25+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
apiMdSha256: f733101c54405189c2d4489a68c838727d12cbddafebbca7469faae6871bb5bf
2+
parserVersion: 0.3.28
3+
pythonVersion: 3.13.14

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_browser_sdk_loader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _register_django_middleware(config: BrowserSDKConfig) -> None:
8787
# Store configuration globally for the middleware to access
8888
_store_django_config(config)
8989
except Exception as ex: # pylint: disable=broad-exception-caught
90-
_logger.warning("Failed to register Django middleware: %s", ex, exc_info=True)
90+
_logger.warning("Failed to register Django middleware: %s", ex, exc_info=True) # pylint: disable=do-not-log-exceptions-if-not-debug
9191

9292

9393
def _store_django_config(config: BrowserSDKConfig) -> None:

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_browser_sdk_loader/django_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
_logger = getLogger(__name__)
2626

27-
27+
# pylint: disable=do-not-log-exceptions-if-not-debug
2828
class ApplicationInsightsWebSnippetMiddleware(MiddlewareMixin):
2929
"""Django middleware for injecting Application Insights web snippet into HTML responses.
3030

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_browser_sdk_loader/snippet_injector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
_logger = getLogger(__name__)
4040

41-
41+
# pylint: disable=do-not-log-exceptions-if-not-debug
4242
def _bounded_decompress(data: bytes, encoding: str) -> bytes:
4343
"""Decompress ``data`` with the given encoding, raising if output exceeds the cap.
4444
@@ -457,7 +457,7 @@ def _decompress_content(self, content: bytes, encoding: Optional[str]) -> bytes:
457457
# Re-raise so callers (e.g., inject_with_compression / should_inject) can
458458
# fall back to returning the original response untouched instead of
459459
# treating still-compressed bytes as HTML and double-compressing them.
460-
_logger.warning("Failed to decompress content with encoding %s: %s", encoding, ex)
460+
_logger.warning("Failed to decompress content with encoding %s: %s", encoding, ex) # pylint: disable=do-not-log-raised-errors
461461
raise
462462
return result
463463

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_diagnostics/diagnostic_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _initialize(cls):
9999
_diagnostic_file_logger.addHandler(f_handler)
100100
cls._initialized = True
101101
except Exception as e: # pylint: disable=broad-except
102-
_logger.error(
102+
_logger.error( # pylint: disable=do-not-log-exceptions-if-not-debug
103103
"Failed to initialize Azure Monitor diagnostic logging: %s", e
104104
) # pylint: disable=do-not-log-exceptions-if-not-debug
105105
cls._initialized = False

sdk/monitor/azure-monitor-opentelemetry/samples/logging/modify_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def on_emit(self, log_record: ReadWriteLogRecord) -> None:
2222
if current_span and getattr(current_span, "name", None):
2323
if log_record.log_record.attributes is None:
2424
log_record.log_record.attributes = {}
25-
log_record.log_record.attributes["ai.operation.name"] = current_span.name # type: ignore[attr-defined, index]
25+
log_record.log_record.attributes["ai.operation.name"] = current_span.name # type: ignore[attr-defined, index] # pylint: disable=line-too-long
2626

2727
def shutdown(self) -> None:
2828
pass

sdk/monitor/azure-monitor-opentelemetry/tests/browserSdkLoader/test_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# --------------------------------------------------------------------------
66

77
import unittest
8-
from unittest.mock import patch, MagicMock
98

109
from azure.monitor.opentelemetry._browser_sdk_loader._config import BrowserSDKConfig
1110

@@ -22,7 +21,10 @@ def test_browser_sdk_config_default_values(self):
2221

2322
def test_browser_sdk_config_custom_values(self):
2423
"""Test BrowserSDKConfig initialization with custom values."""
25-
connection_string = "InstrumentationKey=12345678-1234-1234-1234-123456789012;IngestionEndpoint=https://test.in.applicationinsights.azure.com/"
24+
connection_string = (
25+
"InstrumentationKey=12345678-1234-1234-1234-123456789012;"
26+
+ "IngestionEndpoint=https://test.in.applicationinsights.azure.com/"
27+
)
2628

2729
config = BrowserSDKConfig(enabled=False, connection_string=connection_string)
2830

0 commit comments

Comments
 (0)