beyla icon indicating copy to clipboard operation
beyla copied to clipboard

SQL: Capture full SQL statement instead of `PREPARED STATEMENT`

Open gouthamve opened this issue 9 months ago • 3 comments

Teeing off of https://github.com/grafana/beyla/issues/1695

A lot of the spans say PREPARED STATEMENT . while we should be capturing the underlying SQL calls.

Image

gouthamve avatar Feb 24 '25 13:02 gouthamve

Yeah, this is sort of a limitation of how things work at the moment, with us detecting the SQL statement based on the protocol information. When prepared statement is run, the client supplies the statement ID + the arguments, so the SQL is not actually visible.

I think we need to look into if we can do the same thing we did for gRPC. Namely, if we see the prepare command, then we can create internal mapping SQL statement <> ID and then we can substitute it when someone calls the prepared statement.

Is this Postgres or MySQL?

grcevski avatar Feb 24 '25 14:02 grcevski

This is Postgres. And this is purely on the server side btw. The client sits on a node that doesn't have BTF.

gouthamve avatar Feb 24 '25 14:02 gouthamve

There's currenly a WIP PR for mysql. Postgres can be implemented soon: https://github.com/open-telemetry/opentelemetry-ebpf-instrumentation/pull/256

marctc avatar Jul 07 '25 14:07 marctc