Advanced configuration
This documentation will describe how to fine-tune which telemetry is collected, how often, and from what environments.
Default Configuration
Section titled “Default Configuration”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.
| Field | Type | Default when unset |
|---|---|---|
ProjectID | string | Read from FIREBASE_PROJECT_ID, then GOOGLE_CLOUD_PROJECT, then GCLOUD_PROJECT |
Credentials | *google.Credentials | Application Default Credentials |
Sampler | sdktrace.Sampler | AlwaysOnSampler, so every trace is kept |
MetricExportIntervalMillis | *int | 5000 in dev, 300000 in production. Google Cloud rejects anything below 5000 |
MetricExportTimeoutMillis | *int | Matches MetricExportIntervalMillis |
DisableMetrics | bool | false. Traces and logs are unaffected by this switch |
DisableTraces | bool | false. Metrics and logs are unaffected by this switch |
DisableLoggingInputAndOutput | bool | false, so prompts and model responses are written to Cloud Logging |
ForceDevExport | bool | false, 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, })}Export local telemetry
Section titled “Export local telemetry”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 })}Sampling
Section titled “Sampling”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.
Instrumentation beyond Genkit
Section titled “Instrumentation beyond Genkit”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.
Flush on shutdown
Section titled “Flush on shutdown”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.
What lands in telemetry
Section titled “What lands in telemetry”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.
Disable telemetry
Section titled “Disable telemetry”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.
Disable input and output logging
Section titled “Disable input and output logging”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.
Disable metrics
Section titled “Disable metrics”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.
Disable traces
Section titled “Disable traces”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.