Go trace context in queries
Adding trace context to application queries provides the ability to correlate the queries from a traced transaction, and if sampled, the queries to the transaction trace detail. This feature is also a requirement for the integration of APM with DBO.
Enabling
Trace context can be included automatically using the XSAM/otelsql package. See its usage section on the WithSQLCommenter
feature and the example in apm-go/examples/http at main · solarwinds/apm-go.
Support Matrix
Database type | Client library/framework | Notes |
---|---|---|
Any supported by database/sql that propagates context. See Getting started with otelsql, the OpenTelemetry instrumentation for Go SQL. | GitHub - XSAM/otelsql: OpenTelemetry instrumentation for database/sql | SolarWinds does not recommend enabling this feature if your application uses server-side prepared statements, because the inserted context will likely be incorrect for executions of the statement. |