Performance and errors monitoring
You can monitor DB performance and errors using distributed tracing and metrics. Tracing allows you to see how a request progresses through different services and systems, timings of every operation, any logs and errors as they occur.
go-clickhouse supports tracing and metrics using OpenTelemetry API. OpenTelemetry is a vendor-neutral API for distributed traces and metrics. It specifies how to collect and send telemetry data to backend platforms. It means that you can instrument your application once and then add or change vendors (backends) as required.
go-clickhouse comes with an OpenTelemetry instrumentation called chotel that is distributed as a separate module:
go get github.com/uptrace/go-clickhouse/chotel
To instrument go-clickhouse database, you need to add the hook provided by chotel:
db := ch.Connect(ch.WithDatabase("test"))
You can find a runnable example at GitHub.