Skip to content

Commit 86fc192

Browse files
authored
Merge branch 'dev' into feat/expose-response-headers
2 parents 4c660c7 + 0c619cb commit 86fc192

305 files changed

Lines changed: 14109 additions & 6082 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### General Principles
1010

1111
- Keep things in one function unless composable or reusable
12+
- Do not extract single-use helpers preemptively. Inline the logic at the call site unless the helper is reused, hides a genuinely complex boundary, or has a clear independent name that improves the caller.
1213
- Avoid `try`/`catch` where possible
1314
- Avoid using the `any` type
1415
- Use Bun APIs when possible, like `Bun.file()`

bun.lock

Lines changed: 28 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/monitoring.ts

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { SECRET } from "./secret"
22
import { domain } from "./stage"
33

4+
const description = "Managed by SST (Don't edit in Honeycomb UI)"
5+
46
const webhookRecipient = new honeycomb.WebhookRecipient("DiscordAlerts", {
57
name: $app.stage === "production" ? "Discord Alerts" : `Discord Alerts (${$app.stage})`,
68
url: `https://${domain}/honeycomb/webhook`,
@@ -25,28 +27,43 @@ const webhookRecipient = new honeycomb.WebhookRecipient("DiscordAlerts", {
2527
],
2628
})
2729

30+
// Honeycomb can keep stale query-local calculated fields when the name is unchanged,
31+
// so tie the field name to the expression while avoiding deploy-to-deploy churn.
32+
// https://github.com/honeycombio/terraform-provider-honeycombio/issues/852
33+
const calculatedField = (field: { name: string; expression: string }) => ({
34+
...field,
35+
name: `${field.name}_${(
36+
Array.from(field.expression).reduce((result, char) => Math.imul(31, result) + char.charCodeAt(0), 0) >>> 0
37+
).toString(36)}`,
38+
})
39+
2840
const modelHttpErrorsQuery = (product: "go" | "zen") => {
2941
const filters = [
3042
{ column: "model", op: "exists" },
3143
{ column: "event_type", op: "=", value: "completions" },
3244
{ column: "user_agent", op: "contains", value: "opencode" },
3345
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
3446
]
47+
const failedHttpStatus = calculatedField({
48+
name: "is_failed_http_status",
49+
expression:
50+
product === "go"
51+
? `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401")), NOT(EQUALS($status, "429"))), 1, 0)`
52+
: `IF(AND(EQUALS($status, "429"), $isFreeTier), 0, AND(GTE($status, "400"), NOT(EQUALS($status, "401"))), 1, 0)`,
53+
})
3554

3655
return honeycomb.getQuerySpecificationOutput({
3756
breakdowns: ["model"],
38-
calculatedFields: [
39-
{
40-
name: "is_failed_http_status",
41-
expression:
42-
product === "go"
43-
? `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401")), NOT(EQUALS($status, "429"))), 1, 0)`
44-
: `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401"))), 1, 0)`,
45-
},
46-
],
57+
calculatedFields: [failedHttpStatus],
4758
calculations: [
4859
{ op: "COUNT", name: "TOTAL", filterCombination: "AND", filters },
49-
{ op: "SUM", name: "FAILED", column: "is_failed_http_status", filterCombination: "AND", filters },
60+
{
61+
op: "SUM",
62+
name: "FAILED",
63+
column: failedHttpStatus.name,
64+
filterCombination: "AND",
65+
filters,
66+
},
5067
],
5168
formulas: [{ name: "ERROR", expression: "IF(GTE($TOTAL, 100), DIV($FAILED, $TOTAL), 0)" }],
5269
timeRange: 900,
@@ -59,31 +76,30 @@ const providerHttpErrorsQuery = (product: "go" | "zen") => {
5976
{ column: "user_agent", op: "contains", value: "opencode" },
6077
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
6178
]
79+
const successHttpStatus = calculatedField({
80+
name: "is_success_http_status",
81+
expression: `IF(AND(GTE($status, "200"), LT($status, "400")), 1, 0)`,
82+
})
83+
const failedProviderHttpStatus = calculatedField({
84+
name: "is_failed_provider_http_status",
85+
expression: `IF(GT($llm.error.code, "400"), 1, 0)`,
86+
})
6287

6388
return honeycomb.getQuerySpecificationOutput({
6489
breakdowns: ["provider"],
65-
calculatedFields: [
66-
{
67-
name: "is_success_http_status",
68-
expression: `IF(AND(GTE($status, "200"), LT($status, "400")), 1, 0)`,
69-
},
70-
{
71-
name: "is_failed_provider_http_status",
72-
expression: `IF(GT($llm.error.code, "400"), 1, 0)`,
73-
},
74-
],
90+
calculatedFields: [successHttpStatus, failedProviderHttpStatus],
7591
calculations: [
7692
{
7793
op: "SUM",
7894
name: "SUCCESS",
79-
column: "is_success_http_status",
95+
column: successHttpStatus.name,
8096
filterCombination: "AND",
8197
filters: [...filters, { column: "event_type", op: "=", value: "completions" }],
8298
},
8399
{
84100
op: "SUM",
85101
name: "FAILED",
86-
column: "is_failed_provider_http_status",
102+
column: failedProviderHttpStatus.name,
87103
filterCombination: "AND",
88104
filters: [...filters, { column: "event_type", op: "=", value: "llm.error" }],
89105
},
@@ -95,8 +111,6 @@ const providerHttpErrorsQuery = (product: "go" | "zen") => {
95111
}).json
96112
}
97113

98-
const description = "Managed by SST (Don't edit in Honeycomb UI)"
99-
100114
new honeycomb.Trigger("IncreasedModelHttpErrorsGo", {
101115
name: "Increased Model HTTP Errors [Go]",
102116
description,

nix/hashes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"nodeModules": {
3-
"x86_64-linux": "sha256-LTo0ohJN5hBOubqFLVL45unVEIwBDkACNVv64k2nkq4=",
4-
"aarch64-linux": "sha256-oYKY2UJRWG2fhufW4aGujX/Poou93023ZF2Fu7oyYOw=",
5-
"aarch64-darwin": "sha256-618c9vqKN5I+no1nzylctAiWvqw7Bsa+bzSTNwXmSQA=",
6-
"x86_64-darwin": "sha256-1ro3/gH0FC0TWXwWT+k675xR396GE98HpnBEeuD4t6k="
3+
"x86_64-linux": "sha256-Q9r1S15YL9LQK7DRhuOpw3Fxi24BPovEM995GZJayKw=",
4+
"aarch64-linux": "sha256-C0rRTLnxxuuEkCBc3JZbkR66TUVwpcPFif3BU9GRAuA=",
5+
"aarch64-darwin": "sha256-1HvalOO/pOkRlYH8CZ93psapt90C+pYzui1JCadBE1Q=",
6+
"x86_64-darwin": "sha256-RrndyLWfhWm4mZ88XytFF2NI+ly8la550Z5LBN/g5u4="
77
}
88
}

0 commit comments

Comments
 (0)