Danny Kopping
7d5cd06f83
feat: add aibridge structured logging (#21492)
Closes https://github.com/coder/internal/issues/1151
Sample:
```
[API] 2026-01-13 15:50:20.795 [info] coderd.aibridgedserver: interception started trace=8bb5a1d8eb10526cc46ad90f191bb468 span=a3e5b5da9546032a record_type=interception_start interception_id=97461880-4a6c-47c1-8292-3588dd715312 initiator_id=360c6167-a93a-4442-9c3e-f87a6d1cfb66 api_key_id=vg1sbUv97d provider=anthropic model=claude-opus-4-5-20251101 started_at="2026-01-13T15:50:20.790690781Z" metadata={}
[API] 2026-01-13 15:50:23.741 [info] coderd.aibridgedserver: token usage recorded trace=8bb5a1d8eb10526cc46ad90f191bb468 span=a114f0cc3047296e record_type=token_usage interception_id=97461880-4a6c-47c1-8292-3588dd715312 msg_id=msg_01VJH1rYKspfun8BW29CrYEu input_tokens=10 output_tokens=8 created_at="2026-01-13T15:50:23.731587038Z" metadata={"cache_creation_input":53194,"cache_ephemeral_1h_input":0,"cache_ephemeral_5m_input":53194,"cache_read_input":0,"web_search_requests":0}
[API] 2026-01-13 15:50:26.265 [info] coderd.aibridgedserver: token usage recorded trace=8bb5a1d8eb10526cc46ad90f191bb468 span=dbdafb563bff2c9c record_type=token_usage interception_id=97461880-4a6c-47c1-8292-3588dd715312 msg_id=msg_01VJH1rYKspfun8BW29CrYEu input_tokens=0 output_tokens=130 created_at="2026-01-13T15:50:26.254467904Z" metadata={}
[API] 2026-01-13 15:50:26.268 [info] coderd.aibridgedserver: prompt usage recorded trace=8bb5a1d8eb10526cc46ad90f191bb468 span=da51887a757226fc record_type=prompt_usage interception_id=97461880-4a6c-47c1-8292-3588dd715312 msg_id=msg_01VJH1rYKspfun8BW29CrYEu prompt="list the jmia share price" created_at="2026-01-13T15:50:26.255299811Z" metadata={}
[API] 2026-01-13 15:50:26.268 [info] coderd.aibridgedserver: interception ended trace=8bb5a1d8eb10526cc46ad90f191bb468 span=3fa25397705ee7c9 record_type=interception_end interception_id=97461880-4a6c-47c1-8292-3588dd715312 ended_at="2026-01-13T15:50:26.25555547Z"
[API] 2026-01-13 15:50:26.269 [info] coderd.aibridgedserver: tool usage recorded trace=8bb5a1d8eb10526cc46ad90f191bb468 span=b54af90afc604d29 record_type=tool_usage interception_id=97461880-4a6c-47c1-8292-3588dd715312 msg_id=msg_01VJH1rYKspfun8BW29CrYEu tool=mcp__stonks__getStockPriceSnapshot input="{\"ticker\":\"JMIA\"}" server_url="" injected=false invocation_error="" created_at="2026-01-13T15:50:26.255164652Z" metadata={}
```
Structured logging is only enabled when
`CODER_AIBRIDGE_STRUCTURED_LOGGING=true`.
---------
Signed-off-by: Danny Kopping <danny@coder.com>
2026-01-14 17:26:08 +02:00
..
2025-11-24 18:09:04 +05:00
2025-11-24 18:09:04 +05:00
2025-11-24 18:09:04 +05:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-06-02 20:13:08 -07:00
2025-07-28 14:46:04 +01:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-09-03 10:38:42 +04:00
2025-01-03 13:12:59 +00:00
2025-08-19 10:52:31 +02:00
2025-08-19 10:52:31 +02:00
2025-08-19 10:52:31 +02:00
2025-08-19 10:52:31 +02:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2026-01-08 09:58:10 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-11-25 18:13:00 -07:00
2025-01-03 13:12:59 +00:00
2026-01-08 09:58:10 +00:00
2025-01-03 13:12:59 +00:00
2025-09-11 15:08:57 +02:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-02-19 13:08:38 +00:00
2025-09-11 15:08:57 +02:00
2025-03-21 15:28:08 +00:00
2025-01-03 13:12:59 +00:00
2025-03-21 15:28:08 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-12-22 11:24:00 +11:00
2025-01-03 13:12:59 +00:00
2025-04-04 14:04:20 -04:00
2025-04-04 14:04:20 -04:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-02-24 05:38:17 +00:00
2025-01-03 13:12:59 +00:00
2025-07-02 15:05:42 +00:00
2025-07-02 15:05:42 +00:00
2025-07-02 15:05:42 +00:00
2025-01-27 16:26:56 +00:00
2025-10-06 08:56:43 +00:00
2025-01-27 16:26:56 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-20 17:24:22 +00:00
2025-01-03 13:12:59 +00:00
2025-08-21 16:03:34 -04:00
2025-11-12 14:26:15 -06:00
2025-01-20 17:24:22 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 11:15:35 -06:00
2025-01-03 13:12:59 +00:00
2025-08-13 18:15:53 +01:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2026-01-14 17:26:08 +02:00
2025-07-08 16:16:00 +00:00
2025-01-03 13:12:59 +00:00
2025-05-16 10:09:46 -04:00
2025-03-25 13:54:53 +01:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2026-01-12 15:16:59 +01:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-11-25 13:50:22 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-10-17 13:09:50 -05:00
2025-01-03 13:12:59 +00:00
2025-07-29 16:59:26 +01:00
2025-07-24 16:44:36 +01:00
2025-01-03 13:12:59 +00:00
2025-06-03 16:55:34 +01:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-07-24 16:44:36 +01:00
2025-10-28 15:15:57 +00:00
2025-10-27 17:07:25 +01:00
2025-02-12 18:18:17 +11:00
2025-10-27 17:07:25 +01:00
2025-10-27 17:07:25 +01:00
2025-01-03 13:12:59 +00:00
2025-06-23 09:12:37 +01:00
2025-01-03 13:12:59 +00:00
2025-05-13 20:48:16 +00:00
2025-01-03 13:12:59 +00:00
2025-05-22 19:48:23 +10:00
2025-10-22 16:18:31 +11:00
2025-01-03 13:12:59 +00:00
2025-01-03 13:12:59 +00:00
2025-05-13 20:48:16 +00:00
2025-01-03 13:12:59 +00:00
2025-09-26 11:20:25 +01:00