diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..3b03a07 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,74 @@ + + +## Description +(1-2 sentences: what changed and why — e.g., "Added Firebase push notifications for real-time bus arrivals") + +## Type of Change +- [ ] New feature (`feat`) +- [ ] Bug fix (`fix`) +- [ ] Refactor / code improvement +- [ ] Dependency / build update +- [ ] Documentation +- [ ] Other (explain) + +## Changed Files +(Please list *all* files you changed, each with a description of what you changed and why.) +*Tip: see a list of everything you changed on the "Files changed" tab* + +Example: +* `map_screen.dart` + * Added "New" button to top toolbar +* `bluebus_api.dart` + * Added try/catch statements to `fetchRoutes()` for better reliability + +## Related Issues +Closes #XX, Prereq of #XX, etc. + +## Does your code rely on another PR +(attach PR number here) + +## Testing Done +**Flutter:** +- [ ] Tested on: + - [ ] iOS Simulator + - [ ] Android Emulator + - [ ] Physical device +**Vitest:** +- [ ] existing test(s) with coverage: (which tests?) +- [ ] new tests added: (describe) + +## Screenshots / Demo (if UI or notification change) + + +## Checklist +- [ ] Commit messages follow Conventional Commits +- [ ] PR title follows `(scope): short description` +- [ ] PR target branch is not `main` and is our current working update branch (e.g. `maizebus2.1`, `dev`) +- [ ] No `print()` / `debugPrint()` / `console.log()` left in production code +- [ ] Secrets / keys not committed diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d7f9df..a4ef521 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: do sleep 1 # waits for the walking cache to populate done - sleep 10 # waits for the graph/predictions to be built + sleep 60 # waits for the graph/predictions to be built npx vitest run test Typecheck: diff --git a/package.json b/package.json index 69aa221..ea670a3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "main": "src/app.ts", "scripts": { - "start": "tsx src/app.ts", + "start": "tsx --env-file=.env --experimental-loader=@opentelemetry/instrumentation/hook.mjs --import @/services/observability.ts src/app.ts", "test": "vitest run test", "stress-test": "vitest run test/search-stress.test.ts", "docs": "typedoc --entryPointStrategy expand ./src" @@ -14,6 +14,8 @@ "license": "ISC", "dependencies": { "@datastructures-js/priority-queue": "^6.3.3", + "@hyperdx/node-opentelemetry": "^0.11.0", + "@opentelemetry/host-metrics": "^0.40.0", "axios": "^1.7.2", "dotenv": "^16.4.5", "express": "^4.19.2", diff --git a/src/services/observability.ts b/src/services/observability.ts new file mode 100644 index 0000000..32c7e17 --- /dev/null +++ b/src/services/observability.ts @@ -0,0 +1,26 @@ +import * as HyperDX from '@hyperdx/node-opentelemetry'; +import { HostMetrics } from '@opentelemetry/host-metrics'; +import { metrics } from '@opentelemetry/api' + +// dotenv is NOT used because the otlp endpoint var needs to already be set to work properly +const otelKey = process.env.OTEL_KEY; +const otelExporterOtlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT; +const serviceName = process.env.SERVICE_NAME ?? 'local/mbus-backend-dev'; + +if (otelKey && otelExporterOtlpEndpoint) { + // must be before any meters are created + HyperDX.initSDK({ + apiKey: otelKey, + service: serviceName, + experimentalExceptionCapture: true, + }); + + new HostMetrics({ + meterProvider: metrics.getMeterProvider(), + }).start(); + + console.log('otel initialized as ' + serviceName); +} else { + console.log('otel is off, make sure key and endpoint are set'); +} + diff --git a/src/services/reminder.ts b/src/services/reminder.ts index 509db08..337368f 100644 --- a/src/services/reminder.ts +++ b/src/services/reminder.ts @@ -5,7 +5,7 @@ import { applicationDefault, initializeApp } from "firebase-admin/app"; import * as state from "@/state/transitState"; import { BaseEvent, DelayEvent, eventsEqual, toKey, Key, RegistrationToken, ThresholdEvent, fromKey, delayEvent, thresholdEvent } from "./reminderTypes"; -export * from "./reminderTypes"; +export { baseEvent, fromKey, toKey, registrationToken, sameBaseEvent } from './reminderTypes'; dotenv.config() diff --git a/tsconfig.json b/tsconfig.json index 3422bf1..72796ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true, - // "baseUrl": "./", "paths": { "@/*": [ "./src/*"