|
39 | 39 |
|
40 | 40 | LOGGER = logging.getLogger(__name__) |
41 | 41 |
|
| 42 | +USER_AGENT = f"blueapi cli {__version__}" |
| 43 | + |
42 | 44 |
|
43 | 45 | class UnauthorisedAccessError(Exception): |
44 | 46 | pass |
@@ -277,14 +279,15 @@ def _request_and_deserialize( |
277 | 279 | ) -> T: |
278 | 280 | url = self._config.url.unicode_string().removesuffix("/") + suffix |
279 | 281 | # Get the trace context to propagate to the REST API |
280 | | - carr = get_context_propagator() |
| 282 | + headers = get_context_propagator() |
| 283 | + headers["User-Agent"] = USER_AGENT |
281 | 284 | try: |
282 | 285 | response = self._pool.request( |
283 | 286 | method, |
284 | 287 | url, |
285 | 288 | json=data, |
286 | 289 | params=params, |
287 | | - headers=carr, |
| 290 | + headers=headers, |
288 | 291 | auth=JWTAuth(self._session_manager), |
289 | 292 | ) |
290 | 293 | except requests.exceptions.ConnectionError as ce: |
@@ -312,14 +315,14 @@ def _request_and_deserialize( |
312 | 315 |
|
313 | 316 | def run_blocking(self, req: TaskRequest): |
314 | 317 | url = self._ws_address().unicode_string().removesuffix("/") + "/run_plan" |
315 | | - headers = {} |
| 318 | + headers = get_context_propagator() |
316 | 319 | if self._session_manager: |
317 | 320 | auth = self._session_manager.get_valid_access_token() |
318 | 321 | headers["Authorization"] = f"Bearer {auth}" |
319 | 322 | with connect( |
320 | 323 | url, |
321 | 324 | additional_headers=headers, |
322 | | - user_agent_header="blueapi cli", |
| 325 | + user_agent_header=USER_AGENT, |
323 | 326 | ) as ws: |
324 | 327 | ws.send(req.model_dump_json()) |
325 | 328 | for message in ws: |
|
0 commit comments