Skip to content

Commit

Permalink
common/clickhousedb: update clickhouse-go and advertise client info
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbernat committed Feb 6, 2023
1 parent 79d1bea commit 7acb823
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"akvorado/common/clickhousedb"
"akvorado/common/reporter"
"akvorado/common/schema"
)
Expand All @@ -24,6 +25,7 @@ var (

func init() {
RootCmd.AddCommand(versionCmd)
clickhousedb.AkvoradoVersion = Version
}

var versionCmd = &cobra.Command{
Expand Down
11 changes: 11 additions & 0 deletions common/clickhousedb/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
"akvorado/common/reporter"
)

// AkvoradoVersion is the current version for Akvorado.
var AkvoradoVersion = "dev"

// Component represents the ClickHouse wrapper
type Component struct {
r *reporter.Reporter
Expand Down Expand Up @@ -45,6 +48,14 @@ func New(r *reporter.Reporter, config Configuration, dependencies Dependencies)
MaxOpenConns: config.MaxOpenConns,
MaxIdleConns: config.MaxOpenConns/2 + 1,
ConnMaxLifetime: time.Hour,
ClientInfo: clickhouse.ClientInfo{
Products: []struct {
Name string
Version string
}{
{Name: "akvorado", Version: AkvoradoVersion},
},
},
})
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module akvorado
go 1.19

require (
github.com/ClickHouse/clickhouse-go/v2 v2.5.1
github.com/ClickHouse/clickhouse-go/v2 v2.6.0
github.com/Shopify/sarama v1.38.1
github.com/alecthomas/chroma v0.10.0
github.com/antonmedv/expr v1.11.0
Expand Down Expand Up @@ -51,7 +51,7 @@ require (
)

require (
github.com/ClickHouse/ch-go v0.51.0 // indirect
github.com/ClickHouse/ch-go v0.51.2 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ClickHouse/ch-go v0.51.0 h1:APpjlLifKMgRp1b94cujX7dRZLL4DjbtMVs7qRoUPqg=
github.com/ClickHouse/ch-go v0.51.0/go.mod h1:laZ+vBk0hO3UBQblUXqECDcy71K+/tcIfs7ZjN0evgc=
github.com/ClickHouse/ch-go v0.51.2 h1:PesdqjUImi21U61yPKsDhfer8wiQ3geTsjdjZzXd/3s=
github.com/ClickHouse/ch-go v0.51.2/go.mod h1:z+/hEezvvHvRMV/I00CaXBnxOx+td4zRe7HJpBYLwGU=
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
github.com/ClickHouse/clickhouse-go/v2 v2.5.1 h1:+KebkZtGJKaCilgNF0vQBrc7hOdNWnheue0bX1OVhl4=
github.com/ClickHouse/clickhouse-go/v2 v2.5.1/go.mod h1:21ga8MAMxWl6AKFJTaoT/ur/zIo8OJccxj/5bF8T9SE=
github.com/ClickHouse/clickhouse-go/v2 v2.6.0 h1:NmnPY2Cg4hCqS2ZGBep9EWHfQPAco2Vkpwb02VXtWew=
github.com/ClickHouse/clickhouse-go/v2 v2.6.0/go.mod h1:SvXuWqDsiHJE3VAn2+3+nz9W9exOSigyskcs4DAcxJQ=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Shopify/sarama v1.38.1 h1:lqqPUPQZ7zPqYlWpTh+LQ9bhYNu2xJL6k1SJN4WVe2A=
Expand Down
6 changes: 2 additions & 4 deletions orchestrator/clickhouse/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"akvorado/common/kafka"
"akvorado/common/reporter"
"akvorado/common/schema"

"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
)

func dropAllTables(t *testing.T, ch *clickhousedb.Component) {
Expand Down Expand Up @@ -273,10 +271,10 @@ WHERE database=currentDatabase() AND table NOT LIKE '.%'`)
row := chComponent.QueryRow(context.Background(), `
SELECT query, exception
FROM system.query_log
WHERE client_name = $1
WHERE client_name LIKE 'akvorado/%'
AND query NOT LIKE '%ORDER BY event_time_microseconds%'
ORDER BY event_time_microseconds DESC
LIMIT 1`, proto.ClientName)
LIMIT 1`)
var lastQuery, exception string
if err := row.Scan(&lastQuery, &exception); err == nil {
t.Logf("last ClickHouse query: %s", lastQuery)
Expand Down

0 comments on commit 7acb823

Please sign in to comment.