Skip to content

Advanced configuration

This documentation will describe how to fine-tune which telemetry is collected, how often, and from what environments.

The Firebase telemetry plugin provides default options, out of the box, to get you up and running quickly. These are the provided defaults:

This guide focuses on advanced configuration options for deployed features using the Firebase telemetry plugin. Every option lives on firebase.FirebaseTelemetryOptions, which you pass to firebase.EnableFirebaseTelemetry. Pass nil to take all of the defaults.

FieldTypeDefault when unset
ProjectIDstringRead from FIREBASE_PROJECT_ID, then GOOGLE_CLOUD_PROJECT, then GCLOUD_PROJECT
Credentials*google.CredentialsApplication Default Credentials
Samplersdktrace.SamplerAlwaysOnSampler, so every trace is kept
MetricExportIntervalMillis*int5000 in dev, 300000 in production. Google Cloud rejects anything below 5000
MetricExportTimeoutMillis*intMatches MetricExportIntervalMillis
DisableMetricsboolfalse. Traces and logs are unaffected by this switch
DisableTracesboolfalse. Metrics and logs are unaffected by this switch
DisableLoggingInputAndOutputboolfalse, so prompts and model responses are written to Cloud Logging
ForceDevExportboolfalse, so nothing is exported while GENKIT_ENV=dev

google.Credentials is golang.org/x/oauth2/google.Credentials, and sdktrace is go.opentelemetry.io/otel/sdk/trace.

The two interval fields are *int, so setting them needs an addressable variable:

package main
import (
"github.com/firebase/genkit/go/plugins/firebase"
)
func main() {
interval := 10000 // Milliseconds.
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
ForceDevExport: true,
MetricExportIntervalMillis: &interval,
})
}

Nothing is exported while the process runs in a dev environment. To export telemetry when running locally, turn on the force dev export option.

import "github.com/firebase/genkit/go/plugins/firebase"
func main() {
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
ForceDevExport: true,
})
}

During development and testing, you can decrease latency by adjusting the export interval and timeout.

Note: Shipping to production with a frequent export interval may increase the cost for exported telemetry.

import "github.com/firebase/genkit/go/plugins/firebase"
func main() {
interval := 10000
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
MetricExportIntervalMillis: &interval, // 10 seconds
MetricExportTimeoutMillis: &interval, // 10 seconds
})
}

Sampler accepts any sdktrace.Sampler. Left nil, the plugin keeps every trace, which is fine in development and expensive at production volume: each kept trace costs storage in Cloud Trace and counts against your ingestion quota the same way a short export interval costs money in Cloud Monitoring.

Sample a fraction instead, and wrap it in ParentBased so a trace that starts sampled stays sampled all the way down instead of losing its child spans:

package main
import (
"github.com/firebase/genkit/go/plugins/firebase"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func main() {
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
// Keep 5% of traces. Metrics are unaffected by sampling.
Sampler: sdktrace.ParentBased(sdktrace.TraceIDRatioBased(0.05)),
})
}

Metrics are not sampled, so request counts and token counts stay exact no matter what you set here.

The Go plugin does not auto-instrument anything. Go has no zero-code instrumentation equivalent, so the plugin registers a TracerProvider and a MeterProvider and Genkit’s own actions are the only things that produce spans on them. That includes the model provider plugins, which use plain HTTP clients: a provider call shows up as Genkit’s model span with nothing beneath it. To see the HTTP request as well, hand the plugin a client whose transport is wrapped with otelhttp.NewTransport, through its HTTPClient field where it has one.

To trace your HTTP handlers, your database calls, or any outbound client, add the corresponding OpenTelemetry instrumentation library yourself. For example, wrap your mux in otelhttp before passing it to your server. Those libraries read the global provider at construction time, so build them after you call firebase.EnableFirebaseTelemetry. Their spans then land in the same traces as your flows in Cloud Trace. The Developer UI shows Genkit spans only, so they do not appear there.

The only trace-shaping knobs the plugin itself offers are Sampler, DisableTraces, and DisableMetrics.

The plugin installs its own SIGINT/SIGTERM handler that force-flushes spans and metrics with a five-second budget, then calls os.Exit(0). A process that terminates on a signal loses nothing, and you do not need to sleep for the length of MetricExportIntervalMillis.

For a shutdown path that does not go through a signal, flush explicitly:

package main
import (
"context"
"log"
"github.com/firebase/genkit/go/plugins/googlecloud"
)
func flush(ctx context.Context) {
if err := googlecloud.FlushMetrics(ctx); err != nil {
log.Printf("failed to flush metrics: %v", err)
}
}

googlecloud.FlushMetrics works for Firebase telemetry too, because firebase.EnableFirebaseTelemetry delegates to googlecloud.EnableGoogleCloudTelemetry. Call it after your HTTP server’s Shutdown returns.

DisableLoggingInputAndOutput: true is the only built-in privacy control. It is all or nothing: it removes every prompt and every model response from the exported payloads. There is no field-level or key-level redaction option.

Traces are not the place to look for content either way. The genkit/input and genkit/output span attributes are always <redacted>, because of trace attribute size limits rather than for privacy. The full content travels in the Cloud Logging payloads, which is exactly what DisableLoggingInputAndOutput suppresses.

If you need to keep some content and drop the rest, wrap the span exporter. The redactingSpanExporter pattern in Writing Genkit plugins is the supported way to do it, and it is fine to use from application code, not just from a plugin.

Locally, the Dev UI writes traces to .genkit/traces under your project root, with full inputs and outputs and no expiry. Add .genkit/ to .gitignore, and delete it when you are done with a prompt you would not want kept.

Genkit Monitoring leverages a combination of logging, tracing, and metrics to capture a holistic view of your Genkit interactions, however, you can also disable each of these elements independently if needed.

By default, the Firebase telemetry plugin will capture inputs and outputs for each Genkit feature or step.

To help you control how customer data is stored, you can disable the logging of input and output by adding the following to your configuration:

import "github.com/firebase/genkit/go/plugins/firebase"
func main() {
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
DisableLoggingInputAndOutput: true,
})
}

See What lands in telemetry for what this covers and what it does not.

With this option set, input and output attributes will be redacted in the Genkit Monitoring trace viewer and will be missing from Google Cloud logging.

To disable metrics collection, add the following to your configuration:

import "github.com/firebase/genkit/go/plugins/firebase"
func main() {
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
DisableMetrics: true,
})
}

With this option set, you will no longer see stability metrics in the Genkit Monitoring dashboard and will be missing from Google Cloud Metrics.

To disable trace collection, add the following to your configuration:

import "github.com/firebase/genkit/go/plugins/firebase"
func main() {
firebase.EnableFirebaseTelemetry(&firebase.FirebaseTelemetryOptions{
DisableTraces: true,
})
}

With this option set, you will no longer see traces in the Genkit Monitoring feature page, have access to the trace viewer, or see traces present in Google Cloud Tracing.