11# (c) Copyright IBM Corp. 2025
22
33import os
4- from typing import Any , Dict , List , Sequence , Tuple , Union , Optional
4+ from typing import Any , Dict , List , Optional , Sequence , Tuple , Union
55
66from instana .configurator import config
77from instana .log import logger
@@ -317,7 +317,7 @@ def parse_span_disabling_str(item: str) -> List[str]:
317317 @param item: String span disabling configuration
318318 @return: List of disabled spans
319319 """
320- if item .lower () in SPAN_CATEGORIES or item .lower () in SPAN_TYPE_TO_CATEGORY . keys () :
320+ if item .lower () in SPAN_CATEGORIES or item .lower () in SPAN_TYPE_TO_CATEGORY :
321321 return [item .lower ()]
322322 else :
323323 logger .debug (f"set_span_disabling_str: Invalid span category/type: { item } " )
@@ -335,7 +335,7 @@ def parse_span_disabling_dict(items: Dict[str, bool]) -> Tuple[List[str], List[s
335335 enabled_spans = []
336336
337337 for key , value in items .items ():
338- if key in SPAN_CATEGORIES or key in SPAN_TYPE_TO_CATEGORY . keys () :
338+ if key in SPAN_CATEGORIES or key in SPAN_TYPE_TO_CATEGORY :
339339 if is_truthy (value ):
340340 disabled_spans .append (key )
341341 else :
@@ -394,9 +394,10 @@ def get_disable_trace_configurations_from_yaml() -> Tuple[List[str], List[str]]:
394394
395395
396396def get_disable_trace_configurations_from_local () -> Tuple [List [str ], List [str ]]:
397- if "tracing" in config :
398- if tracing_disable_config := config ["tracing" ].get ("disable" , None ):
399- return parse_span_disabling (tracing_disable_config )
397+ if "tracing" in config and (
398+ tracing_disable_config := config ["tracing" ].get ("disable" , None )
399+ ):
400+ return parse_span_disabling (tracing_disable_config )
400401 return [], []
401402
402403
@@ -472,15 +473,15 @@ def parse_technology_stack_trace_config(
472473 tech_stack_config = {}
473474 context = f"for { tech_name } " if tech_name else ""
474475
475- if level_key in tech_data :
476- if validated_level := validate_stack_trace_level (tech_data [level_key ], context ):
477- tech_stack_config ["level" ] = validated_level
476+ if level_key in tech_data and (
477+ validated_level := validate_stack_trace_level (tech_data [level_key ], context )
478+ ):
479+ tech_stack_config ["level" ] = validated_level
478480
479- if length_key in tech_data :
480- if validated_length := validate_stack_trace_length (
481- tech_data [length_key ], context
482- ):
483- tech_stack_config ["length" ] = validated_length
481+ if length_key in tech_data and (
482+ validated_length := validate_stack_trace_length (tech_data [length_key ], context )
483+ ):
484+ tech_stack_config ["length" ] = validated_length
484485
485486 return tech_stack_config
486487
@@ -498,17 +499,19 @@ def parse_global_stack_trace_config(global_config: Dict[str, Any]) -> Tuple[str,
498499 level = "all"
499500 length = 30
500501
501- if "stack-trace" in global_config :
502- if validated_level := validate_stack_trace_level (
502+ if "stack-trace" in global_config and (
503+ validated_level := validate_stack_trace_level (
503504 global_config ["stack-trace" ], "in YAML config"
504- ):
505- level = validated_level
505+ )
506+ ):
507+ level = validated_level
506508
507- if "stack-trace-length" in global_config :
508- if validated_length := validate_stack_trace_length (
509+ if "stack-trace-length" in global_config and (
510+ validated_length := validate_stack_trace_length (
509511 global_config ["stack-trace-length" ], "in YAML config"
510- ):
511- length = validated_length
512+ )
513+ ):
514+ length = validated_length
512515
513516 return level , length
514517
@@ -544,9 +547,9 @@ def parse_tech_specific_stack_trace_configs(
544547 return tech_config
545548
546549
547- def get_stack_trace_config_from_yaml () -> (
548- Tuple [ str , int , Dict [str , Dict [str , Union [str , int ] ]]]
549- ) :
550+ def get_stack_trace_config_from_yaml () -> Tuple [
551+ str , int , Dict [str , Dict [str , Union [str , int ]]]
552+ ] :
550553 """
551554 Get stack trace configuration from YAML file specified by INSTANA_CONFIG_PATH.
552555
0 commit comments