Telemetry collection
The Firebase telemetry plugin exports a combination of metrics, traces, and logs to Google Cloud Observability. This document details which metrics, trace attributes, and logs will be collected and what you can expect in terms of latency, quotas, and cost.
Telemetry delay
Section titled “Telemetry delay”There may be a slight delay before telemetry from a given invocation is available in Firebase. This is dependent on your export interval (5 minutes by default).
Quotas and limits
Section titled “Quotas and limits”There are several quotas that are important to keep in mind:
Cloud Logging, Cloud Trace, and Cloud Monitoring have generous free-of-charge tiers. Specific pricing can be found at the following links:
enable_google_cloud_telemetry() exports telemetry that follows the
OpenTelemetry GenAI semantic conventions.
It installs GenAiInstrumentation from genkit-otel unless one is already
configured. It does not write the genkit/feature/*, genkit/action/*, or
genkit/ai/generate/* metrics, or the [genkit] Input[...] style log entries.
Metrics
Section titled “Metrics”GenAiInstrumentation records two histograms for every model call on the
process MeterProvider. Metrics are not sampled.
gen_ai.client.token.usage: histogram of token counts, split bygen_ai.token.type(inputoroutput).gen_ai.client.operation.duration: histogram of model call latency in seconds, for successful and failed calls. Failures carryerror.type, the exception class name.
Both carry gen_ai.operation.name (chat), gen_ai.request.model, and
gen_ai.provider.name when the provider is known.
Traces
Section titled “Traces”Each Genkit request produces one connected trace in Cloud Trace:
- Model spans (
chat <model>):CLIENTspans with thegen_ai.*attributes listed in What gets emitted. - Tool spans (
execute_tool <name>):INTERNALspans withgen_ai.tool.nameandgen_ai.tool.type = 'function'. Emitted only when you configureGenAiInstrumentation(emit_tool_spans=True)before callingenable_google_cloud_telemetry(). - Other action spans (
<action name>):INTERNALspans withgenkit.action.type, such asfloworretriever, so model calls nest under their flow. If a tool or flow raisesInterrupt, the span getsgenkit.interrupted = Trueand no error status.
Before export, GcpAdjustingTraceExporter adjusts each span for Cloud Trace:
:in attribute keys becomes/, sogenkit:metadata:<key>arrives asgenkit/metadata/<key>.- Spans with an error status get
/http/status_code = '599', so Cloud Trace highlights them. - Zero-length spans are padded to 1 microsecond.
Prompt and response events are off by default. Turn them on with
content_capturing_mode='EVENT_ONLY' or 'SPAN_AND_EVENT', either on
GenAiInstrumentation before you call enable_google_cloud_telemetry() or
through OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. See
Capturing message content.
Each model call then emits a gen_ai.client.inference.operation.details log
record with gen_ai.input.messages, gen_ai.output.messages, and
gen_ai.system_instructions. With emit_tool_spans=True, each tool call emits
one with gen_ai.tool.call.arguments and gen_ai.tool.call.result. Records go
to Cloud Logging under the log name gen_ai.client.inference.operation.details.
Sensitive data
Section titled “Sensitive data”- Cloud Trace does not store prompt or reply content: before export,
GcpAdjustingTraceExporterreplaces these attributes with'<redacted>':gen_ai.input.messages,gen_ai.output.messages,gen_ai.system_instructions,gen_ai.tool.call.arguments,gen_ai.tool.call.result,genkit.input,genkit.output,genkit:input,genkit:output,genkit:metadata:interrupt, andgenkit:metadata:resumed. - Genkit span errors are redacted too:
str(exc), for example from a PydanticValidationError, can quote prompt or tool payloads. On spans Genkit created, the status description,exception.message, andexception.stacktracebecome'<redacted>'.error.typeandexception.typeare kept. - Other spans pass through unchanged: spans from HTTP frameworks, database drivers, or your own code keep their attributes and exception messages.
- Cloud Logging is not redacted: with
EVENT_ONLYorSPAN_AND_EVENT, the operation-details records carry the full prompt, reply, system instructions, and tool payloads to Cloud Logging. - Your own exporters see the content: with
content_capturing_mode='SPAN_ONLY'orcapture_action_io=True, aSpanExporteryou attach to the sameTracerProviderreceives the unredacted attributes. Only the Cloud Trace export is redacted.