@@ -74,7 +74,6 @@ def new_client(
7474 tag_truncate_conf : Optional [TagTruncateConf ] = None ,
7575 api_base_path : Optional [APIBasePath ] = None ,
7676 trace_queue_conf : Optional [QueueConf ] = None ,
77- header_injector : Optional [Callable [[], Dict [str , str ]]] = None ,
7877) -> Client :
7978 cache_key = _generate_cache_key ( # all args are used to generate cache key
8079 api_base_url ,
@@ -94,7 +93,6 @@ def new_client(
9493 tag_truncate_conf ,
9594 api_base_path ,
9695 trace_queue_conf ,
97- header_injector ,
9896 )
9997
10098 with _cache_lock :
@@ -120,7 +118,6 @@ def new_client(
120118 tag_truncate_conf = tag_truncate_conf ,
121119 api_base_path = api_base_path ,
122120 trace_queue_conf = trace_queue_conf ,
123- header_injector = header_injector ,
124121 )
125122 _client_cache [cache_key ] = client
126123 return client
@@ -152,7 +149,6 @@ def __init__(
152149 tag_truncate_conf : Optional [TagTruncateConf ] = None ,
153150 api_base_path : Optional [APIBasePath ] = None ,
154151 trace_queue_conf : Optional [QueueConf ] = None ,
155- header_injector : Optional [Callable [[], Dict [str , str ]]] = None ,
156152 ):
157153 workspace_id = self ._get_from_env (workspace_id , ENV_WORKSPACE_ID )
158154 api_base_url = self ._get_from_env (api_base_url , ENV_API_BASE_URL )
@@ -185,18 +181,14 @@ def __init__(
185181 jwt_oauth_private_key = jwt_oauth_private_key ,
186182 jwt_oauth_public_key_id = jwt_oauth_public_key_id
187183 )
188-
189- # 创建默认的header注入函数
190- if header_injector is None :
191- header_injector = self ._create_default_header_injector ()
192-
184+
193185 http_client = httpclient .Client (
194186 api_base_url = api_base_url ,
195187 http_client = inner_client ,
196188 auth = auth ,
197189 timeout = timeout ,
198190 upload_timeout = upload_timeout ,
199- header_injector = header_injector ,
191+ header_injector = self . _create_default_header_injector () ,
200192 )
201193 finish_pro = default_finish_event_processor
202194 if trace_finish_event_processor :
@@ -230,14 +222,12 @@ def combined_processor(event_info: FinishEventInfo):
230222 )
231223
232224 def _create_default_header_injector (self ) -> Callable [[], Dict [str , str ]]:
233- """创建默认的header注入函数,包含span header注入逻辑"""
234225 def default_header_injector () -> Dict [str , str ]:
235226 try :
236227 span = self .get_span_from_context ()
237228 if span and hasattr (span , 'to_header' ):
238229 return span .to_header ()
239230 except Exception :
240- # 静默处理异常,不影响正常请求
241231 pass
242232 return {}
243233 return default_header_injector
0 commit comments