summaryrefslogtreecommitdiffhomepage
path: root/packages/console/function/src/log-processor.ts
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-02-10 15:55:31 -0500
committerFrank <[email protected]>2026-02-10 15:55:33 -0500
commit8c56571ef95df398fff683253649414a1681c6f6 (patch)
treecb578ff66f24e531a9b6c640da682c565037f05c /packages/console/function/src/log-processor.ts
parent92a77b72fb67f2a80663a5ee3599c5d044255934 (diff)
downloadopencode-8c56571ef95df398fff683253649414a1681c6f6.tar.gz
opencode-8c56571ef95df398fff683253649414a1681c6f6.zip
zen: log error
Diffstat (limited to 'packages/console/function/src/log-processor.ts')
-rw-r--r--packages/console/function/src/log-processor.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/packages/console/function/src/log-processor.ts b/packages/console/function/src/log-processor.ts
index 9e76e2ceb..d5d6318ba 100644
--- a/packages/console/function/src/log-processor.ts
+++ b/packages/console/function/src/log-processor.ts
@@ -17,7 +17,7 @@ export default {
)
return
- let metrics = {
+ let data = {
event_type: "completions",
"cf.continent": event.event.request.cf?.continent,
"cf.country": event.event.request.cf?.country,
@@ -31,22 +31,28 @@ export default {
status: event.event.response?.status ?? 0,
ip: event.event.request.headers["x-real-ip"],
}
+ const time = event.eventTimestamp ?? Date.now()
+ const events = []
for (const log of event.logs) {
for (const message of log.message) {
if (!message.startsWith("_metric:")) continue
- metrics = { ...metrics, ...JSON.parse(message.slice(8)) }
+ const json = JSON.parse(message.slice(8))
+ data = { ...data, ...json }
+ if ("llm.error.code" in json) {
+ events.push({ time, data: { ...data } })
+ }
}
}
- console.log(JSON.stringify(metrics, null, 2))
+ events.push({ time, data })
+ console.log(JSON.stringify(data, null, 2))
- const ret = await fetch("https://api.honeycomb.io/1/events/zen", {
+ const ret = await fetch("https://api.honeycomb.io/1/batch/zen", {
method: "POST",
headers: {
"Content-Type": "application/json",
- "X-Honeycomb-Event-Time": (event.eventTimestamp ?? Date.now()).toString(),
"X-Honeycomb-Team": Resource.HONEYCOMB_API_KEY.value,
},
- body: JSON.stringify(metrics),
+ body: JSON.stringify(events),
})
console.log(ret.status)
console.log(await ret.text())