infra: stats
Some checks are pending
deploy / deploy (push) Waiting to run
generate / generate (push) Waiting to run
nix-eval / nix-eval (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Waiting to run
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Waiting to run
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Waiting to run
nix-hashes / update-hashes (push) Blocked by required conditions
publish / sign-cli-windows (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
publish / publish (push) Blocked by required conditions
publish / version (push) Waiting to run
publish / build-cli (push) Blocked by required conditions
storybook / storybook build (push) Waiting to run
test / unit (linux) (push) Waiting to run
test / unit (windows) (push) Waiting to run
test / e2e (linux) (push) Waiting to run
test / e2e (windows) (push) Waiting to run
typecheck / typecheck (push) Waiting to run

This commit is contained in:
Frank 2026-06-02 02:41:33 -04:00
parent 6a5ef7f2ea
commit 90d85636e0
3 changed files with 49 additions and 9 deletions

View file

@ -268,6 +268,7 @@ export const lakeIngest = new sst.Linkable("LakeIngest", {
secret: ingestSecret.result,
},
})
export const lakeIngestSecret = new sst.Secret("LakeIngestSecret", ingestSecret.result)
export const lakeQueryPermissions = [
{
@ -320,3 +321,39 @@ export const lakeQueryPermissions = [
resources: ["*"],
},
]
////////////////
// S3 Tables
////////////////
const modelsNamespace = new aws.s3tables.Namespace("LakeModelsNamespace", {
namespace: "models",
tableBucketArn: tableBucket.arn,
})
new aws.s3tables.Table(
"LakeModelsEventTable",
{
name: "hit",
namespace: modelsNamespace.namespace,
tableBucketArn: modelsNamespace.tableBucketArn,
format: "ICEBERG",
metadata: {
iceberg: {
schema: {
fields: [
{ name: "event_timestamp", type: "string", required: false },
{ name: "event_date", type: "string", required: false },
{ name: "event_type", type: "string", required: false },
{ name: "country", type: "string", required: false },
{ name: "user_agent", type: "string", required: false },
{ name: "ip", type: "string", required: false },
{ name: "ip_prefix", type: "string", required: false },
{ name: "path", type: "string", required: false },
],
},
},
},
},
{ deleteBeforeReplace: $app.stage !== "production" },
)

View file

@ -1,11 +1,6 @@
import { lakeAthenaWorkgroup, lakeCatalog, lakeCluster, lakeQueryPermissions, lakeRegion, tableBucket } from "./lake"
import { EMAILOCTOPUS_API_KEY } from "./app"
const domain = (() => {
if ($app.stage === "production") return "stats.opencode.ai"
if ($app.stage === "dev") return "stats.dev.opencode.ai"
return `stats.${$app.stage}.dev.opencode.ai`
})()
import { domain } from "./stage"
////////////////
// LAKE
@ -42,6 +37,7 @@ const inferenceEventTable = new aws.s3tables.Table(
{ name: "request_length", type: "long", required: false },
{ name: "status", type: "int", required: false },
{ name: "ip", type: "string", required: false },
{ name: "ip_prefix", type: "string", required: false },
{ name: "is_stream", type: "boolean", required: false },
{ name: "session", type: "string", required: false },
{ name: "request", type: "string", required: false },
@ -167,10 +163,10 @@ new sst.x.DevCommand("StatsStudio", {
export const app = new sst.cloudflare.x.SolidStart("Stats", {
path: "packages/stats/app",
buildCommand: "bun run build",
domain,
domain: `stats.${domain}`,
link: [database, EMAILOCTOPUS_API_KEY],
environment: {
PUBLIC_URL: `https://${domain}/stats`,
PUBLIC_URL: `https://stats.${domain}/stats`,
},
})

View file

@ -30,7 +30,8 @@ export default $config({
async run() {
const stage = await import("./infra/stage.js")
await import("./infra/app.js")
const stats = stage.deployAws ? await import("./infra/lake.js").then(() => import("./infra/stats.js")) : undefined
const lake = stage.deployAws ? await import("./infra/lake.js") : undefined
const stats = stage.deployAws ? await import("./infra/stats.js") : undefined
const { stat } = await import("./infra/console.js")
await import("./infra/enterprise.js")
if ($app.stage === "production" || $app.stage === "vimtor") {
@ -40,6 +41,12 @@ export default $config({
return {
StatWorkerUrl: stat.url,
...(stats ? { StatsUrl: stats.app.url } : {}),
...(lake
? {
LakeUrl: lake.lakeIngest.properties.url,
LakeSecretName: lake.lakeIngestSecret.name,
}
: {}),
AwsStage: stage.awsStage,
}
},