@@ -96,11 +96,11 @@ def _import_config_components(
9696
9797 for selected_component in selected_components :
9898 try :
99- component_implementations .append (
100- (
99+ component_implementations .append ( # type: ignore[misc] # <will add tracking issue num>
100+ ( # type: ignore[misc] # <will add tracking issue num>
101101 selected_component ,
102- next (
103- iter (
102+ next ( # type: ignore[misc] # <will add tracking issue num>
103+ iter ( # type: ignore[misc] # <will add tracking issue num>
104104 entry_points (
105105 group = entry_point_name , name = selected_component
106106 )
@@ -121,7 +121,7 @@ def _import_config_components(
121121 f"entry point '{ entry_point_name } '"
122122 )
123123
124- return component_implementations
124+ return component_implementations # type: ignore[misc] # <will add tracking issue num>
125125
126126
127127def _get_sampler () -> Optional [str ]:
@@ -132,7 +132,7 @@ def _get_id_generator() -> str:
132132 return environ .get (OTEL_PYTHON_ID_GENERATOR , _DEFAULT_ID_GENERATOR )
133133
134134
135- def _get_exporter_entry_point (
135+ def _get_exporter_entry_point ( # type: ignore[no-untyped-def] # <will add tracking issue num>
136136 exporter_name : str , signal_type : Literal ["traces" , "metrics" , "logs" ]
137137):
138138 if exporter_name not in (
@@ -185,16 +185,16 @@ def _get_exporter_names(
185185 return []
186186
187187 return [
188- _get_exporter_entry_point (_exporter .strip (), signal_type )
188+ _get_exporter_entry_point (_exporter .strip (), signal_type ) # type: ignore[misc] # <will add tracking issue num>
189189 for _exporter in names .split ("," )
190190 ]
191191
192192
193- def _init_tracing (
193+ def _init_tracing ( # type: ignore[no-untyped-def] # <will add tracking issue num>
194194 exporters : Dict [str , Type [SpanExporter ]],
195- id_generator : IdGenerator = None ,
196- sampler : Sampler = None ,
197- resource : Resource = None ,
195+ id_generator : IdGenerator = None , # type: ignore[assignment] # <will add tracking issue num>
196+ sampler : Sampler = None , # type: ignore[assignment] # <will add tracking issue num>
197+ resource : Resource = None , # type: ignore[assignment] # <will add tracking issue num>
198198):
199199 provider = TracerProvider (
200200 id_generator = id_generator ,
@@ -204,47 +204,47 @@ def _init_tracing(
204204 set_tracer_provider (provider )
205205
206206 for _ , exporter_class in exporters .items ():
207- exporter_args = {}
207+ exporter_args = {} # type: ignore[var-annotated] # <will add tracking issue num>
208208 provider .add_span_processor (
209- BatchSpanProcessor (exporter_class (** exporter_args ))
209+ BatchSpanProcessor (exporter_class (** exporter_args )) # type: ignore[misc] # <will add tracking issue num>
210210 )
211211
212212
213- def _init_metrics (
213+ def _init_metrics ( # type: ignore[no-untyped-def] # <will add tracking issue num>
214214 exporters_or_readers : Dict [
215215 str , Union [Type [MetricExporter ], Type [MetricReader ]]
216216 ],
217- resource : Resource = None ,
217+ resource : Resource = None , # type: ignore[assignment] # <will add tracking issue num>
218218):
219219 metric_readers = []
220220
221221 for _ , exporter_or_reader_class in exporters_or_readers .items ():
222- exporter_args = {}
222+ exporter_args = {} # type: ignore[var-annotated] # <will add tracking issue num>
223223
224224 if issubclass (exporter_or_reader_class , MetricReader ):
225- metric_readers .append (exporter_or_reader_class (** exporter_args ))
225+ metric_readers .append (exporter_or_reader_class (** exporter_args )) # type: ignore[misc] # <will add tracking issue num>
226226 else :
227227 metric_readers .append (
228228 PeriodicExportingMetricReader (
229- exporter_or_reader_class (** exporter_args )
229+ exporter_or_reader_class (** exporter_args ) # type: ignore[misc] # <will add tracking issue num>
230230 )
231231 )
232232
233233 provider = MeterProvider (resource = resource , metric_readers = metric_readers )
234234 set_meter_provider (provider )
235235
236236
237- def _init_logging (
237+ def _init_logging ( # type: ignore[no-untyped-def] # <will add tracking issue num>
238238 exporters : Dict [str , Type [LogExporter ]],
239- resource : Resource = None ,
239+ resource : Resource = None , # type: ignore[assignment] # <will add tracking issue num>
240240):
241241 provider = LoggerProvider (resource = resource )
242242 set_logger_provider (provider )
243243
244244 for _ , exporter_class in exporters .items ():
245- exporter_args = {}
245+ exporter_args = {} # type: ignore[var-annotated] # <will add tracking issue num>
246246 provider .add_log_record_processor (
247- BatchLogRecordProcessor (exporter_class (** exporter_args ))
247+ BatchLogRecordProcessor (exporter_class (** exporter_args )) # type: ignore[misc] # <will add tracking issue num>
248248 )
249249
250250 handler = LoggingHandler (level = logging .NOTSET , logger_provider = provider )
@@ -266,39 +266,39 @@ def _import_exporters(
266266 log_exporters = {}
267267
268268 for (exporter_name , exporter_impl ,) in _import_config_components (
269- trace_exporter_names , "opentelemetry_traces_exporter"
269+ trace_exporter_names , "opentelemetry_traces_exporter" # type: ignore[arg-type] # <will add tracking issue num>
270270 ):
271- if issubclass (exporter_impl , SpanExporter ):
271+ if issubclass (exporter_impl , SpanExporter ): # type: ignore[arg-type] # <will add tracking issue num>
272272 trace_exporters [exporter_name ] = exporter_impl
273273 else :
274274 raise RuntimeError (f"{ exporter_name } is not a trace exporter" )
275275
276276 for (exporter_name , exporter_impl ,) in _import_config_components (
277- metric_exporter_names , "opentelemetry_metrics_exporter"
277+ metric_exporter_names , "opentelemetry_metrics_exporter" # type: ignore[arg-type] # <will add tracking issue num>
278278 ):
279279 # The metric exporter components may be push MetricExporter or pull exporters which
280280 # subclass MetricReader directly
281- if issubclass (exporter_impl , (MetricExporter , MetricReader )):
281+ if issubclass (exporter_impl , (MetricExporter , MetricReader )): # type: ignore[arg-type] # <will add tracking issue num>
282282 metric_exporters [exporter_name ] = exporter_impl
283283 else :
284284 raise RuntimeError (f"{ exporter_name } is not a metric exporter" )
285285
286286 for (exporter_name , exporter_impl ,) in _import_config_components (
287- log_exporter_names , "opentelemetry_logs_exporter"
287+ log_exporter_names , "opentelemetry_logs_exporter" # type: ignore[arg-type] # <will add tracking issue num>
288288 ):
289- if issubclass (exporter_impl , LogExporter ):
289+ if issubclass (exporter_impl , LogExporter ): # type: ignore[arg-type] # <will add tracking issue num>
290290 log_exporters [exporter_name ] = exporter_impl
291291 else :
292292 raise RuntimeError (f"{ exporter_name } is not a log exporter" )
293293
294- return trace_exporters , metric_exporters , log_exporters
294+ return trace_exporters , metric_exporters , log_exporters # type: ignore[return-value] # <will add tracking issue num>
295295
296296
297297def _import_sampler_factory (sampler_name : str ) -> Callable [[str ], Sampler ]:
298298 _ , sampler_impl = _import_config_components (
299299 [sampler_name .strip ()], _OTEL_SAMPLER_ENTRY_POINT_GROUP
300300 )[0 ]
301- return sampler_impl
301+ return sampler_impl # type: ignore[return-value] # <will add tracking issue num>
302302
303303
304304def _import_sampler (sampler_name : str ) -> Optional [Sampler ]:
@@ -309,17 +309,17 @@ def _import_sampler(sampler_name: str) -> Optional[Sampler]:
309309 arg = None
310310 if sampler_name in ("traceidratio" , "parentbased_traceidratio" ):
311311 try :
312- rate = float (os .getenv (OTEL_TRACES_SAMPLER_ARG ))
312+ rate = float (os .getenv (OTEL_TRACES_SAMPLER_ARG )) # type: ignore[arg-type] # <will add tracking issue num>
313313 except (ValueError , TypeError ):
314314 _logger .warning (
315315 "Could not convert TRACES_SAMPLER_ARG to float. Using default value 1.0."
316316 )
317317 rate = 1.0
318318 arg = rate
319319 else :
320- arg = os .getenv (OTEL_TRACES_SAMPLER_ARG )
320+ arg = os .getenv (OTEL_TRACES_SAMPLER_ARG ) # type: ignore[assignment] # <will add tracking issue num>
321321
322- sampler = sampler_factory (arg )
322+ sampler = sampler_factory (arg ) # type: ignore[arg-type] # <will add tracking issue num>
323323 if not isinstance (sampler , Sampler ):
324324 message = f"Sampler factory, { sampler_factory } , produced output, { sampler } , which is not a Sampler."
325325 _logger .warning (message )
@@ -339,36 +339,36 @@ def _import_id_generator(id_generator_name: str) -> IdGenerator:
339339 [id_generator_name .strip ()], "opentelemetry_id_generator"
340340 )[0 ]
341341
342- if issubclass (id_generator_impl , IdGenerator ):
343- return id_generator_impl ()
342+ if issubclass (id_generator_impl , IdGenerator ): # type: ignore[arg-type] # <will add tracking issue num>
343+ return id_generator_impl () # type: ignore[misc, no-any-return, operator] # <will add tracking issue num>
344344
345345 raise RuntimeError (f"{ id_generator_name } is not an IdGenerator" )
346346
347347
348- def _initialize_components (auto_instrumentation_version ):
348+ def _initialize_components (auto_instrumentation_version ): # type: ignore[no-untyped-def] # <will add tracking issue num>
349349 trace_exporters , metric_exporters , log_exporters = _import_exporters (
350350 _get_exporter_names ("traces" ),
351351 _get_exporter_names ("metrics" ),
352352 _get_exporter_names ("logs" ),
353353 )
354354 sampler_name = _get_sampler ()
355- sampler = _import_sampler (sampler_name )
355+ sampler = _import_sampler (sampler_name ) # type: ignore[arg-type] # <will add tracking issue num>
356356 id_generator_name = _get_id_generator ()
357357 id_generator = _import_id_generator (id_generator_name )
358358 # if env var OTEL_RESOURCE_ATTRIBUTES is given, it will read the service_name
359359 # from the env variable else defaults to "unknown_service"
360360 auto_resource = {}
361361 # populate version if using auto-instrumentation
362- if auto_instrumentation_version :
363- auto_resource [
362+ if auto_instrumentation_version : # type: ignore[misc] # <will add tracking issue num>
363+ auto_resource [ # type: ignore[misc] # <will add tracking issue num>
364364 ResourceAttributes .TELEMETRY_AUTO_VERSION
365- ] = auto_instrumentation_version
366- resource = Resource .create (auto_resource )
365+ ] = auto_instrumentation_version # type: ignore[misc] # <will add tracking issue num>
366+ resource = Resource .create (auto_resource ) # type: ignore[misc] # <will add tracking issue num>
367367
368368 _init_tracing (
369369 exporters = trace_exporters ,
370370 id_generator = id_generator ,
371- sampler = sampler ,
371+ sampler = sampler , # type: ignore[arg-type] # <will add tracking issue num>
372372 resource = resource ,
373373 )
374374 _init_metrics (metric_exporters , resource )
@@ -390,20 +390,20 @@ class _BaseConfigurator(ABC):
390390 _instance = None
391391 _is_instrumented = False
392392
393- def __new__ (cls , * args , ** kwargs ):
393+ def __new__ (cls , * args , ** kwargs ): # type: ignore[no-untyped-def] # <will add tracking issue num>
394394
395395 if cls ._instance is None :
396- cls ._instance = object .__new__ (cls , * args , ** kwargs )
396+ cls ._instance = object .__new__ (cls , * args , ** kwargs ) # type: ignore[misc] # <will add tracking issue num>
397397
398398 return cls ._instance
399399
400400 @abstractmethod
401- def _configure (self , ** kwargs ):
401+ def _configure (self , ** kwargs ): # type: ignore[misc, no-untyped-def] # <will add tracking issue num>
402402 """Configure the SDK"""
403403
404- def configure (self , ** kwargs ):
404+ def configure (self , ** kwargs ): # type: ignore[no-untyped-def] # <will add tracking issue num>
405405 """Configure the SDK"""
406- self ._configure (** kwargs )
406+ self ._configure (** kwargs ) # type: ignore[misc, no-untyped-call] # <will add tracking issue num>
407407
408408
409409class _OTelSDKConfigurator (_BaseConfigurator ):
@@ -418,5 +418,5 @@ class _OTelSDKConfigurator(_BaseConfigurator):
418418 this Configurator and enhance it as needed.
419419 """
420420
421- def _configure (self , ** kwargs ):
422- _initialize_components (kwargs .get ("auto_instrumentation_version" ))
421+ def _configure (self , ** kwargs ): # type: ignore[no-untyped-def] # <will add tracking issue num>
422+ _initialize_components (kwargs .get ("auto_instrumentation_version" )) # type: ignore[misc, no-untyped-call] # <will add tracking issue num>
0 commit comments