mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-14 08:32:33 +00:00
chore: add free tier usage alert
This commit is contained in:
@@ -169,3 +169,38 @@ new honeycomb.Trigger("IncreasedProviderHttpErrorsZen", {
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
new honeycomb.Trigger("IncreasedFreeTierRequests", {
|
||||
disabled: true,
|
||||
name: "Increased Free Tier Requests",
|
||||
description,
|
||||
queryJson: honeycomb.getQuerySpecificationOutput({
|
||||
calculations: [
|
||||
{
|
||||
op: "COUNT",
|
||||
name: "REQUESTS",
|
||||
filterCombination: "AND",
|
||||
filters: [
|
||||
{ column: "event_type", op: "=", value: "completions" },
|
||||
{ column: "user_agent", op: "contains", value: "opencode" },
|
||||
{ column: "isFreeTier", op: "=", value: "true" },
|
||||
],
|
||||
},
|
||||
],
|
||||
timeRange: 14400,
|
||||
}).json,
|
||||
alertType: "on_change",
|
||||
frequency: 3600,
|
||||
thresholds: [{ op: ">=", value: 50, exceededLimit: 2 }],
|
||||
baselineDetails: [{ type: "percentage", offsetMinutes: 1440 }],
|
||||
recipients: [
|
||||
{
|
||||
id: webhookRecipient.id,
|
||||
notificationDetails: [
|
||||
{
|
||||
variables: [{ name: "type", value: "custom" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
@@ -23,15 +23,19 @@ const honeycombWebhookPayload = z.discriminatedUnion("type", [
|
||||
type: z.literal("provider_http_errors"),
|
||||
groups,
|
||||
}),
|
||||
basePayload.extend({
|
||||
type: z.literal("custom"),
|
||||
}),
|
||||
])
|
||||
|
||||
const postDiscordMessage = async (payload: z.infer<typeof honeycombWebhookPayload>) => {
|
||||
const group = payload.type === "model_http_errors" ? "model" : "provider"
|
||||
const names = (payload.groups ?? []).flatMap((item) => item.group.map((g) => g.value))
|
||||
const group =
|
||||
payload.type === "model_http_errors" ? "model" : payload.type === "provider_http_errors" ? "provider" : undefined
|
||||
const names = payload.type === "custom" ? [] : payload.groups.flatMap((item) => item.group.map((g) => g.value))
|
||||
|
||||
const content = [
|
||||
`[**${payload.isTest ? "[TEST] " : ""}${payload.name ?? "Honeycomb alert"}**](${payload.url})`,
|
||||
names.length > 0 ? `Affected ${group}s:` : undefined,
|
||||
group && names.length > 0 ? `Affected ${group}s:` : undefined,
|
||||
...names.map((name) => `- ${name}`),
|
||||
"",
|
||||
`<@&${DISCORD_ALERT_ROLE_ID}>`,
|
||||
|
||||
Reference in New Issue
Block a user