Skip to content

Commit e644278

Browse files
authored
feat: override user agent for databend-go client (#2)
1 parent 2f7bf51 commit e644278

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/databendlabs/grafana-databend-datasource
33
go 1.25.7
44

55
require (
6-
github.com/datafuselabs/databend-go v0.9.2
6+
github.com/datafuselabs/databend-go v0.9.3
77
github.com/grafana/grafana-plugin-sdk-go v0.292.0
88
github.com/grafana/sqlds/v4 v4.1.3
99
github.com/magefile/mage v1.17.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsV
2828
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
2929
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
3030
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
31-
github.com/datafuselabs/databend-go v0.9.2 h1:J5Nk1Q/9sjX3HX0RC4mUpHJ/JLsu2NqZq6tXkhRsSbg=
32-
github.com/datafuselabs/databend-go v0.9.2/go.mod h1:G90oi9bpPFdwpBeRW1DNBYjLsEtzFVq8R5nZCPqNn1Q=
31+
github.com/datafuselabs/databend-go v0.9.3 h1:oPKOZcGQPpIQ5246ymPrmDn7AzRXWo8ADMoQ1Nu5gbU=
32+
github.com/datafuselabs/databend-go v0.9.3/go.mod h1:4gZSxuLaYCITyrPz5I9VI0gLwf2KHIasfhedYDpmb10=
3333
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3434
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3535
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datasource-databend",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Grafana datasource plugin for Databend",
55
"scripts": {
66
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",

pkg/plugin/driver.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"net/url"
88

9-
_ "github.com/datafuselabs/databend-go"
9+
godatabend "github.com/datafuselabs/databend-go"
1010
"github.com/grafana/grafana-plugin-sdk-go/backend"
1111
"github.com/grafana/grafana-plugin-sdk-go/data"
1212
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
@@ -16,6 +16,8 @@ import (
1616
"github.com/databendlabs/grafana-databend-datasource/pkg/macros"
1717
)
1818

19+
const userAgent = "grafana-databend-datasource"
20+
1921
// Databend defines how to connect to a Databend datasource
2022
type Databend struct{}
2123

@@ -37,7 +39,12 @@ func (d *Databend) Connect(ctx context.Context, config backend.DataSourceInstanc
3739
} else {
3840
dsn = settings.DSN
3941
}
40-
return sql.Open("databend", dsn)
42+
cfg, err := godatabend.ParseDSN(dsn)
43+
if err != nil {
44+
return nil, err
45+
}
46+
cfg.UserAgent = userAgent
47+
return sql.OpenDB(cfg), nil
4148
}
4249

4350
// Converters defines list of data type converters

0 commit comments

Comments
 (0)