-
Notifications
You must be signed in to change notification settings - Fork 37
feat(gastown): add observability infrastructure #1075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7cf1652
feat(gastown): add observability — structured logging, event streamin…
jrf0110 08e09d0
fix(gastown): use @cloudflare/workers-types via tsconfig instead of r…
jrf0110 0095648
fix(gastown): address review feedback on observability infrastructure
jrf0110 828a009
feat(gastown): add Sentry sourcemap uploads and clean up DSN config
jrf0110 e067d3b
feat(gastown): instrument all HTTP routes and tRPC procedures with an…
jrf0110 a46499e
fix(gastown): drop all CHECK constraints from DO SQLite tables
jrf0110 70886a7
feat(admin): add Gastown analytics dashboard with charts
jrf0110 dbd1f81
feat(gastown): add Grafana dashboard for Analytics Engine data
jrf0110 7903305
fix(gastown): fix Grafana dashboard panel queries for ClickHouse data…
jrf0110 a1e2d41
fix(gastown): remove subqueries from Analytics Engine SQL queries
jrf0110 b53a6c7
fix(gastown): address review feedback and fix lint/format
jrf0110 c3443c6
fix(gastown): address remaining review comments
jrf0110 bd3be82
fix(gastown): fix event name collisions, latency dilution, and format…
jrf0110 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| .dev.vars | ||
| container/dist/ | ||
| dist-types/ | ||
|
|
||
| # Sentry Config File | ||
| .sentryclirc | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * Structured logger for the container process. | ||
| * | ||
| * Outputs JSON to console.* so entries appear in Workers Logs | ||
| * (captured via `observability: { enabled: true }` in wrangler.jsonc). | ||
| * Keep this module dependency-free and synchronous. | ||
| */ | ||
|
|
||
| function flatten(data?: unknown): Record<string, unknown> { | ||
| if (!data || typeof data !== 'object') return {}; | ||
| return data as Record<string, unknown>; | ||
| } | ||
|
|
||
| export const log = { | ||
| info: (msg: string, data?: unknown) => | ||
| console.log( | ||
| JSON.stringify({ level: 'info', msg, ...flatten(data), ts: new Date().toISOString() }) | ||
| ), | ||
| warn: (msg: string, data?: unknown) => | ||
| console.warn( | ||
| JSON.stringify({ level: 'warn', msg, ...flatten(data), ts: new Date().toISOString() }) | ||
| ), | ||
| error: (msg: string, data?: unknown) => | ||
| console.error( | ||
| JSON.stringify({ level: 'error', msg, ...flatten(data), ts: new Date().toISOString() }) | ||
| ), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| import { startControlServer } from './control-server'; | ||
| import { log } from './logger'; | ||
|
|
||
| log.info('container.cold_start', { uptime: 0, ts: new Date().toISOString() }); | ||
|
|
||
| process.on('uncaughtException', err => { | ||
| log.error('container.uncaught_exception', { error: err.message, stack: err.stack }); | ||
| process.exit(1); | ||
| }); | ||
|
|
||
| startControlServer(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Immediate exit can drop the crash log
process.exit(1)terminates the process synchronously, so thecontainer.uncaught_exceptionentry emitted just above is not guaranteed to flush to stderr/Workers Logs first. That makes the only structured signal for this failure mode easy to lose during postmortems.