3838
3939LOGGER = logging .getLogger (__name__ )
4040
41+ USER_AGENT = f"blueapi cli { __version__ } "
42+
4143
4244class UnauthorisedAccessError (Exception ):
4345 pass
@@ -260,14 +262,15 @@ def _request_and_deserialize(
260262 ) -> T :
261263 url = self ._config .url .unicode_string ().removesuffix ("/" ) + suffix
262264 # Get the trace context to propagate to the REST API
263- carr = get_context_propagator ()
265+ headers = get_context_propagator ()
266+ headers ["User-Agent" ] = USER_AGENT
264267 try :
265268 response = self ._pool .request (
266269 method ,
267270 url ,
268271 json = data ,
269272 params = params ,
270- headers = carr ,
273+ headers = headers ,
271274 auth = JWTAuth (self ._session_manager ),
272275 )
273276 except requests .exceptions .ConnectionError as ce :
@@ -293,14 +296,14 @@ def _request_and_deserialize(
293296
294297 def run_blocking (self , req : TaskRequest ):
295298 url = self ._ws_address ().unicode_string ().removesuffix ("/" ) + "/run_plan"
296- headers = {}
299+ headers = get_context_propagator ()
297300 if self ._session_manager :
298301 auth = self ._session_manager .get_valid_access_token ()
299302 headers ["Authorization" ] = f"Bearer { auth } "
300303 with connect (
301304 url ,
302305 additional_headers = headers ,
303- user_agent_header = "blueapi cli" ,
306+ user_agent_header = USER_AGENT ,
304307 ) as ws :
305308 ws .send (req .model_dump_json ())
306309 for message in ws :
0 commit comments