Skip to content

Commit 7063a28

Browse files
authored
Mypy for azure monitor distro (Azure#32954)
1 parent dab018e commit 7063a28

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/collector/sample_collector.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Telemetry is exported to application insights with the AzureMonitorTraceExporter and Zipkin with the
77
OTLP Span exporter.
88
"""
9+
# mypy: disable-error-code="attr-defined"
910
import os
1011
from opentelemetry import trace
1112

sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/example/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3+
# mypy: disable-error-code="attr-defined"
34
import os
45

56
from django.http import HttpResponse

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
OTEL_METRICS_EXPORTER,
1212
OTEL_TRACES_EXPORTER,
1313
)
14-
from opentelemetry.instrumentation.distro import (
14+
from opentelemetry.instrumentation.distro import ( # type: ignore
1515
BaseDistro,
1616
)
1717
from opentelemetry.sdk.environment_variables import (

sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from opentelemetry.instrumentation.dependencies import (
1313
get_dist_dependency_conflicts,
1414
)
15-
from opentelemetry.instrumentation.instrumentor import (
15+
from opentelemetry.instrumentation.instrumentor import ( # type: ignore
1616
BaseInstrumentor,
1717
)
1818
from opentelemetry.metrics import set_meter_provider
@@ -119,7 +119,7 @@ def _setup_tracing(configurations: Dict[str, ConfigurationValue]):
119119
span_processor = BatchSpanProcessor(
120120
trace_exporter,
121121
)
122-
get_tracer_provider().add_span_processor(span_processor)
122+
get_tracer_provider().add_span_processor(span_processor) # type: ignore
123123
if _is_instrumentation_enabled(configurations, _AZURE_SDK_INSTRUMENTATION_NAME):
124124
settings.tracing_implementation = OpenTelemetrySpan
125125

@@ -131,9 +131,9 @@ def _setup_logging(configurations: Dict[str, ConfigurationValue]):
131131
log_record_processor = BatchLogRecordProcessor(
132132
log_exporter,
133133
)
134-
get_logger_provider().add_log_record_processor(log_record_processor)
134+
get_logger_provider().add_log_record_processor(log_record_processor) # type: ignore
135135
handler = LoggingHandler(logger_provider=get_logger_provider())
136-
logger_name = configurations[LOGGER_NAME_ARG]
136+
logger_name = configurations[LOGGER_NAME_ARG] # type: ignore
137137
getLogger(logger_name).addHandler(handler)
138138

139139

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ def _initialize(cls):
7676
AzureDiagnosticLogging._initialized = True
7777

7878
@classmethod
79-
def info(cls, message: str, message_id: int):
79+
def info(cls, message: str, message_id: str):
8080
AzureDiagnosticLogging._initialize()
8181
_logger.info(message, extra={'msgId': message_id})
8282

8383
@classmethod
84-
def warning(cls, message: str, message_id: int):
84+
def warning(cls, message: str, message_id: str):
8585
AzureDiagnosticLogging._initialize()
8686
_logger.warning(message, extra={'msgId': message_id})
8787

8888
@classmethod
89-
def error(cls, message: str, message_id: int):
89+
def error(cls, message: str, message_id: str):
9090
AzureDiagnosticLogging._initialize()
9191
_logger.error(message, extra={'msgId': message_id})

sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/sample/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# cSpell:disable
1616

1717
from pathlib import Path
18+
from typing import List
1819

1920
# Build paths inside the project like this: BASE_DIR / 'subdir'.
2021
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -29,7 +30,7 @@
2930
# SECURITY WARNING: don't run with debug turned on in production!
3031
DEBUG = True
3132

32-
ALLOWED_HOSTS = []
33+
ALLOWED_HOSTS: List[str] = []
3334

3435

3536
# Application definition

0 commit comments

Comments
 (0)