-
Notifications
You must be signed in to change notification settings - Fork 299
feat(js): Enable Firebase Genkit Monitoring via an environment variable #3043
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
base: main
Are you sure you want to change the base?
Conversation
9535cf6
to
835c449
Compare
@@ -42,12 +42,41 @@ const instrumentationKey = '__GENKIT_TELEMETRY_INSTRUMENTED'; | |||
* @hidden | |||
*/ | |||
export async function ensureBasicTelemetryInstrumentation() { | |||
await checkFirebaseMonitoringAutoInit(); |
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.
There is some very relevant refactoring happening: #3062
But I think this change is probably OK. If we go ahead with that refactor, we'll just move this call into node implementation of instrumentation.
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.
Let me know if I should wait for that, or if this can go.
process.env.ENABLE_FIREBASE_MONITORING === 'true' | ||
) { | ||
try { | ||
const firebaseModule = await require('@genkit-ai/firebase'); |
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.
can you please test this with ESM (next.js or angular SSR)?
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.
Ran a nextjs app locally with and without the firebase plugin - it warns when I expect it to and loads the firebase plugin and configures it when I expect it to.
I noticed that the telemetry server didn't automatically get configured when I didn't have firebase installed. Do we expect a local telemetry server to exist without the GENKIT_TELEMETRY_SERVER environment variable and without Firebase? I don't think this is related to my change, but I suppose it could be.
Logs
Without the firebase plugin installed --
$ npm run dev
> [email protected] dev
> next dev --turbopack
▲ Next.js 15.3.3 (Turbopack)
- Local: http://localhost:3000
- Network: http://172.18.89.178:3000
✓ Starting...
✓ Ready in 1316ms
○ Compiling / ...
✓ Compiled / in 3.1s
GET / 200 in 3489ms
○ Compiling /_not-found/page ...
GET /.well-known/appspecific/com.chrome.devtools.json 404 in 1363ms
✓ Compiled /_not-found/page in 1450ms
GET /favicon.ico?favicon.45db1c09.ico 200 in 1370ms
POST /api/menuSuggestion 404 in 111ms
GET /api/menuSuggestion 404 in 160ms
○ Compiling /api/menuSuggestion ...
GET / 200 in 595ms
GET / 200 in 150ms
GET /favicon.ico?favicon.45db1c09.ico 200 in 444ms
✓ Compiled /api/menuSuggestion in 4s
registering /util/generate
Registering plugin googleai...
registering /flow/menuSuggestionFlow
GET /api/menuSuggestion 405 in 4759ms
GET /api/menuSuggestion 405 in 78ms
GET /api/menuSuggestion 405 in 89ms
It looks like you're trying to enable firebase monitoring, but haven't installed the firebase plugin. Please run `npm i --save @genkit-ai/firebase` and redeploy.
Initializing plugin googleai:
registering /model/googleai/gemini-1.5-pro
registering /model/googleai/gemini-1.5-flash
registering /model/googleai/gemini-1.5-flash-8b
registering /model/googleai/gemini-2.0-flash
registering /model/googleai/gemini-2.0-flash-lite
registering /model/googleai/gemini-2.0-pro-exp-02-05
registering /model/googleai/gemini-2.0-flash-exp
registering /model/googleai/gemini-2.5-pro-exp-03-25
registering /model/googleai/gemini-2.5-pro-preview-03-25
registering /model/googleai/gemini-2.5-flash-preview-04-17
registering /model/googleai/gemini-2.5-flash-preview-tts
registering /embedder/googleai/embedding-001
registering /embedder/googleai/text-embedding-004
POST /api/menuSuggestion 200 in 3328ms
Telemetry server is not configured, trace e2e2bfeb3481db580f0da965581784c7 not saved!
With the plugin installed --
$ npm run dev
> [email protected] dev
> next dev --turbopack
▲ Next.js 15.3.3 (Turbopack)
- Local: http://localhost:3000
- Network: http://172.18.89.178:3000
✓ Starting...
✓ Ready in 2s
○ Compiling / ...
✓ Compiled / in 3.2s
GET / 200 in 3723ms
○ Compiling /_not-found/page ...
GET /.well-known/appspecific/com.chrome.devtools.json 404 in 1249ms
✓ Compiled /_not-found/page in 1452ms
GET /favicon.ico?favicon.45db1c09.ico 200 in 1283ms
○ Compiling /api/menuSuggestion ...
✓ Compiled /api/menuSuggestion in 5.5s
registering /util/generate
Registering plugin googleai...
registering /flow/menuSuggestionFlow
Initializing Firebase Genkit Monitoring.
POST /api/menuSuggestion 200 in 10350ms
Allow developers to turn Firebase Genkit Monitoring on and off via environment variables.
Checklist (if applicable):
Docs will need to be updated in a subsequent PR.