1414 - GCROptions - Options class for Google cloud Run. Holds settings specific to GCR.
1515"""
1616
17+ from __future__ import annotations
18+
1719import logging
1820import os
19- from typing import Any , Dict , Sequence , Tuple
21+ from collections .abc import Sequence
22+ from typing import Any
2023
2124from instana .configurator import config
2225from instana .log import logger
4144class BaseOptions (object ):
4245 """Base class for all option classes. Holds items common to all"""
4346
44- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
47+ def __init__ (self , ** kwds : object ) -> None :
4548 self .debug = False
4649 self .log_level = logging .WARN
4750 self .service_name = determine_service_name ()
@@ -324,7 +327,7 @@ def is_span_disabled(self, category=None, span_type=None) -> bool:
324327 # Default: not disabled
325328 return False
326329
327- def get_stack_trace_config (self , span_name : str ) -> Tuple [str , int ]:
330+ def get_stack_trace_config (self , span_name : str ) -> tuple [str , int ]:
328331 """
329332 Get stack trace configuration for a specific span type.
330333 Technology-specific configuration overrides global configuration.
@@ -362,7 +365,7 @@ class StandardOptions(BaseOptions):
362365 DEFAULT_POLL_RATE = 1
363366 MAX_POLL_RATE = 5
364367
365- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
368+ def __init__ (self , ** kwds : object ) -> None :
366369 super (StandardOptions , self ).__init__ ()
367370
368371 self .agent_host = os .environ .get ("INSTANA_AGENT_HOST" , self .AGENT_DEFAULT_HOST )
@@ -372,7 +375,7 @@ def __init__(self, **kwds: Dict[str, Any]) -> None:
372375 if not isinstance (self .agent_port , int ):
373376 self .agent_port = int (self .agent_port )
374377
375- def set_secrets (self , secrets : Dict [str , Any ]) -> None :
378+ def set_secrets (self , secrets : dict [str , str | list [ str ] ]) -> None :
376379 """
377380 Set the secret option from the agent config.
378381 @param secrets: dictionary of secrets
@@ -381,7 +384,7 @@ def set_secrets(self, secrets: Dict[str, Any]) -> None:
381384 self .secrets_matcher = secrets ["matcher" ]
382385 self .secrets_list = secrets ["list" ]
383386
384- def set_extra_headers (self , extra_headers : Dict [str , Any ]) -> None :
387+ def set_extra_headers (self , extra_headers : list [str ]) -> None :
385388 """
386389 Set the extra headers option from the agent config, which uses the legacy configuration setting.
387390 @param extra_headers: dictionary of headers
@@ -395,7 +398,7 @@ def set_extra_headers(self, extra_headers: Dict[str, Any]) -> None:
395398 f"Will also capture these custom headers: { self .extra_http_headers } "
396399 )
397400
398- def set_tracing (self , tracing : Dict [str , Any ]) -> None :
401+ def set_tracing (self , tracing : dict [str , Any ]) -> None :
399402 """
400403 Set tracing options from the agent config.
401404 @param tracing: tracing configuration dictionary
@@ -417,7 +420,7 @@ def set_tracing(self, tracing: Dict[str, Any]) -> None:
417420 # Handle stack trace configuration from agent config
418421 self .set_stack_trace_from_agent (tracing )
419422
420- def _apply_agent_filter_config (self , filter_config : Any ) -> None :
423+ def _apply_agent_filter_config (self , filter_config : dict [ str , Any ] ) -> None :
421424 """Apply span filter rules from agent config."""
422425 parsed = parse_filter_rules (filter_config )
423426 for policy in ("exclude" , "include" ):
@@ -427,7 +430,7 @@ def _apply_agent_filter_config(self, filter_config: Any) -> None:
427430 self .span_filters [policy ] = []
428431 self .span_filters [policy ].extend (rules )
429432
430- def _apply_agent_kafka_config (self , kafka_config : Dict [str , Any ]) -> None :
433+ def _apply_agent_kafka_config (self , kafka_config : dict [str , str | bool ]) -> None :
431434 """Apply Kafka tracing configuration from agent config."""
432435 no_env_override = "INSTANA_KAFKA_TRACE_CORRELATION" not in os .environ
433436 no_code_override = not (
@@ -476,7 +479,7 @@ def _should_apply_agent_global_config(self) -> bool:
476479 return not (has_env_vars or has_yaml_config or has_in_code_config )
477480
478481 def _apply_agent_global_stack_trace_config (
479- self , global_config : Dict [str , Any ]
482+ self , global_config : dict [str , Any ]
480483 ) -> None :
481484 """Apply global stack trace configuration from agent config."""
482485 if "stack-trace" in global_config and (
@@ -493,7 +496,7 @@ def _apply_agent_global_stack_trace_config(
493496 ):
494497 self .stack_trace_length = validated_length
495498
496- def _apply_agent_tech_stack_trace_config (self , tracing : Dict [str , Any ]) -> None :
499+ def _apply_agent_tech_stack_trace_config (self , tracing : dict [str , Any ]) -> None :
497500 """Apply technology-specific stack trace configuration from agent config."""
498501 for tech_name , tech_config in tracing .items ():
499502 if tech_name == "global" or not isinstance (tech_config , dict ):
@@ -509,7 +512,7 @@ def _apply_agent_tech_stack_trace_config(self, tracing: Dict[str, Any]) -> None:
509512 if tech_stack_config :
510513 self .stack_trace_technology_config [tech_name ] = tech_stack_config
511514
512- def set_stack_trace_from_agent (self , tracing : Dict [str , Any ]) -> None :
515+ def set_stack_trace_from_agent (self , tracing : dict [str , Any ]) -> None :
513516 """
514517 Set stack trace configuration from agent config (configuration.yaml).
515518 Only applies if not already set by higher priority sources.
@@ -524,7 +527,7 @@ def set_stack_trace_from_agent(self, tracing: Dict[str, Any]) -> None:
524527 if not self .stack_trace_technology_config :
525528 self ._apply_agent_tech_stack_trace_config (tracing )
526529
527- def set_disable_tracing (self , tracing_config : Sequence [Dict [str , Any ]]) -> None :
530+ def set_disable_tracing (self , tracing_config : Sequence [dict [str , Any ]]) -> None :
528531 # The precedence is as follows:
529532 # environment variables > in-code (local) config > agent config (configuration.yaml)
530533 if (
@@ -540,7 +543,7 @@ def set_disable_tracing(self, tracing_config: Sequence[Dict[str, Any]]) -> None:
540543 self .disabled_spans .extend (disabled_spans )
541544 self .enabled_spans .extend (enabled_spans )
542545
543- def set_poll_rate (self , plugin_config : Dict [str , Any ]) -> None :
546+ def set_poll_rate (self , plugin_config : dict [str , Any ]) -> None :
544547 """Set poll rate from agent plugin configuration."""
545548 poll_rate_value = plugin_config .get ("poll_rate" )
546549 if poll_rate_value is None :
@@ -568,7 +571,7 @@ def set_poll_rate(self, plugin_config: Dict[str, Any]) -> None:
568571 )
569572 self .poll_rate = self .DEFAULT_POLL_RATE
570573
571- def set_from (self , res_data : Dict [str , Any ]) -> None :
574+ def set_from (self , res_data : dict [str , Any ]) -> None :
572575 """
573576 Set the source identifiers given to use by the Instana Host agent.
574577 @param res_data: source identifiers provided as announce response
@@ -598,7 +601,7 @@ def set_from(self, res_data: Dict[str, Any]) -> None:
598601class ServerlessOptions (BaseOptions ):
599602 """Base class for serverless environments. Holds settings common to all serverless environments."""
600603
601- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
604+ def __init__ (self , ** kwds : object ) -> None :
602605 super (ServerlessOptions , self ).__init__ ()
603606
604607 self .agent_key = os .environ .get ("INSTANA_AGENT_KEY" , None )
@@ -657,14 +660,14 @@ def __init__(self, **kwds: Dict[str, Any]) -> None:
657660class AWSLambdaOptions (ServerlessOptions ):
658661 """Options class for AWS Lambda. Holds settings specific to AWS Lambda."""
659662
660- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
663+ def __init__ (self , ** kwds : object ) -> None :
661664 super (AWSLambdaOptions , self ).__init__ ()
662665
663666
664667class AWSFargateOptions (ServerlessOptions ):
665668 """Options class for AWS Fargate. Holds settings specific to AWS Fargate."""
666669
667- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
670+ def __init__ (self , ** kwds : object ) -> None :
668671 super (AWSFargateOptions , self ).__init__ ()
669672
670673 self .tags = None
@@ -689,12 +692,12 @@ def __init__(self, **kwds: Dict[str, Any]) -> None:
689692class EKSFargateOptions (AWSFargateOptions ):
690693 """Options class for EKS Pods on AWS Fargate. Holds settings specific to EKS Pods on AWS Fargate."""
691694
692- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
695+ def __init__ (self , ** kwds : object ) -> None :
693696 super (EKSFargateOptions , self ).__init__ ()
694697
695698
696699class GCROptions (ServerlessOptions ):
697700 """Options class for Google Cloud Run. Holds settings specific to Google Cloud Run."""
698701
699- def __init__ (self , ** kwds : Dict [ str , Any ] ) -> None :
702+ def __init__ (self , ** kwds : object ) -> None :
700703 super (GCROptions , self ).__init__ ()
0 commit comments