-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add SQLCommenter observability to all sources #2899
Copy link
Copy link
Open
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Prerequisites
- Search the current open issues
What are you trying to do that currently feels hard or impossible?
Summary
Introduce a centralized SQLCommenter integration that automatically appends
metadata (action, controller, db_driver, traceparent) to every
database request (SQL statements and BigQuery job labels). This will give
operators full trace correlation between AI‑driven tool calls and the
underlying database activity.
Motivation
- Unified observability – no longer need to sprinkle manual comment logic
in each tool implementation. - Trace correlation – the OpenTelemetry
traceparenttag lets Cloud
Monitoring link the AI request to the database query. - Zero runtime overhead – only a string concatenation before the query is
executed. - Future‑proof – new database sources automatically inherit the behavior.
Suggested Solution(s)
Proposed Design (high‑level)
- Core helper –
internal/sqlcommenter/commenter.gowill expose
AppendComment(ctx, sql)that reads the requestcontextfor:toolName(the tool being executed)controller(the agent name, fromTOOLBOX_AGENT_NAME)db_driver(derived from the source type)traceparent(from the current OpenTelemetry span, if any)
- Context injection – modify
internal/server/api.go(and the MCP
method files) to storetoolNameandcontrollerin the request context
before the tool handler runs. - Source updates – each source’s
RunSQLmethod calls
sqlcommenter.AppendCommentbefore executing the query.
This includes Postgres, MySQL, BigQuery, SQLite, MSSQL, CockroachDB,
AlloyDB, SingleStore, etc. - BigQuery job labels – the same tags are added to
JobLabelsso they
appear in Cloud Logging. - OpenTelemetry – add the
traceparenttag to enable end‑to‑end tracing. - Tests – add unit tests (
internal/sqlcommenter/commenter_test.go) that
verify the generated comment contains all fields when the context is set. - Documentation – add a design note in
docs/sqlcommenter_design.md
Alternatives Considered
No response
Additional Details
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.