Skip to content

Commit

Permalink
Update Firebase plugin to support passing project ID to gcp telemetry…
Browse files Browse the repository at this point in the history
… when specified via environment variable. (#498)
  • Loading branch information
bryanatkinson authored Jul 8, 2024
1 parent c85367f commit af977cc
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions js/plugins/firebase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
GcpOpenTelemetry,
TelemetryConfig,
} from '@genkit-ai/google-cloud';
import { GoogleAuth } from 'google-auth-library';
import { FirestoreTraceStore } from './firestoreTraceStore.js';
export { defineFirestoreRetriever } from './firestoreRetriever.js';

Expand All @@ -39,24 +40,31 @@ interface FirestorePluginParams {

export const firebase: Plugin<[FirestorePluginParams] | []> = genkitPlugin(
'firebase',
async (params?: FirestorePluginParams) => ({
flowStateStore: {
id: 'firestore',
value: new FirestoreStateStore(params?.flowStateStore),
},
traceStore: {
id: 'firestore',
value: new FirestoreTraceStore(params?.traceStore),
},
telemetry: {
instrumentation: {
id: 'firebase',
value: new GcpOpenTelemetry(params),
async (params?: FirestorePluginParams) => {
const authClient = new GoogleAuth();
const gcpOptions = {
projectId: params?.projectId || (await authClient.getProjectId()),
telemetryConfig: params?.telemetryConfig,
};
return {
flowStateStore: {
id: 'firestore',
value: new FirestoreStateStore(params?.flowStateStore),
},
logger: {
id: 'firebase',
value: new GcpLogger(params),
traceStore: {
id: 'firestore',
value: new FirestoreTraceStore(params?.traceStore),
},
},
})
telemetry: {
instrumentation: {
id: 'firebase',
value: new GcpOpenTelemetry(gcpOptions),
},
logger: {
id: 'firebase',
value: new GcpLogger(gcpOptions),
},
},
};
}
);

0 comments on commit af977cc

Please sign in to comment.