ConversationalSearchService through the openlayer Ruby gem. Once you trace a client, every
answer_query call it makes is published to Openlayer with the query, the grounded answer,
latency, and the retrieval steps Discovery Engine ran to produce that answer.
This tracer is Ruby only, and it is separate from the Dialogflow
CX integration. Dialogflow CX reads agent logs
from BigQuery; this tracer wraps a Discovery Engine SDK client in your own
process.
Install and require
Install the Openlayer gem alongside the Google Discovery Engine client:require "openlayer", so require it explicitly:
Prerequisites:
- A project in Openlayer with monitoring mode enabled.
- An Openlayer API key.
- The inference pipeline ID of the data source you want to publish to.
Trace a ConversationalSearchService client
Pass your Google client totrace_client. It patches answer_query on that client instance, so
you keep calling the Google SDK exactly as you did before:
serving_config and query
as keyword arguments as above.
Sessions, users, additional columns
trace_client takes the following keyword arguments:
When you do not set
session_id, Openlayer falls back to the session on the request, and when
you do not set user_id, it falls back to user_pseudo_id on the response’s session. Either way,
you can group and filter traces by session and user in Openlayer.
To attach data to a single call rather than to every call, pass additional_columns to
answer_query. The tracer strips that argument before forwarding the call, so Google never sees
it:
query, answer, latency_ms, timestamp,
metadata, steps, context, session_id, and user_id.
What is captured
Eachanswer_query call becomes one row with the query, the answer text, the latency, and the
request timestamp. The row carries a single top-level step named Conversational Search
answer_query, recorded with provider Google and model google-discovery-engine.
Underneath that step, Openlayer captures:
- Retrieval steps: each execution step Discovery Engine reports becomes a retriever step, showing the rephrased query next to your original one and the documents it returned.
- Grounding: citations, references, and related questions, when the answer includes them.
- Context: the content of the answer’s references, so the context column is populated for retrieval-based tests.
- Metadata: the serving config, the grounding score, the answer state, citation and reference counts, and any reasons the answer was skipped.