Class FirebaseTelemetry
java.lang.Object
com.google.genkit.plugins.firebase.telemetry.FirebaseTelemetry
Firebase telemetry integration for Genkit Monitoring.
Configures OpenTelemetry to export traces and metrics to Google Cloud, enabling Firebase Genkit Monitoring features.
This class does NOT define any new metrics - it simply configures exporters to send the existing Genkit core metrics (from GenerateTelemetry, ToolTelemetry, etc.) to Google Cloud Monitoring.
Key capabilities:
- View quantitative metrics like latency, errors, and token usage in Cloud Monitoring
- Inspect traces in Cloud Trace to see flow steps, inputs, and outputs
- Export production traces to run evaluations
Example usage:
// Enable telemetry via Firebase plugin builder
FirebasePlugin.builder().projectId("my-project").enableTelemetry(true).forceDevExport(true) // Enable in dev mode
.build();
Prerequisites:
- Set GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable
- Configure Google Cloud credentials (GOOGLE_APPLICATION_CREDENTIALS or default credentials)
- Enable Cloud Trace and Cloud Monitoring APIs in your GCP project
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for FirebaseTelemetry. -
Method Summary
Modifier and TypeMethodDescriptionstatic FirebaseTelemetry.Builderbuilder()Creates a builder for FirebaseTelemetry.voidenable()Enables telemetry collection and export to Google Cloud.static voidEnables Firebase telemetry with default configuration based on environment.booleanChecks if telemetry is enabled.voidshutdown()Shuts down the telemetry exporters.
-
Method Details
-
builder
Creates a builder for FirebaseTelemetry.- Returns:
- a new builder
-
enableFromEnvironment
public static void enableFromEnvironment()Enables Firebase telemetry with default configuration based on environment.Checks for ENABLE_FIREBASE_MONITORING environment variable.
-
enable
public void enable()Enables telemetry collection and export to Google Cloud.This configures:
- Trace export to Google Cloud Trace via Genkit's core Tracer
- Metric export to Google Cloud Monitoring via GlobalOpenTelemetry
The existing Genkit metrics (GenerateTelemetry, ToolTelemetry) use GlobalOpenTelemetry.getMeter(), so once we configure the global meter provider with a Google Cloud exporter, those metrics will be automatically exported.
-
isEnabled
public boolean isEnabled()Checks if telemetry is enabled.- Returns:
- true if enabled
-
shutdown
public void shutdown()Shuts down the telemetry exporters.
-