Skip to content

Commit

Permalink
Use go.nhat.io packages instead of github (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm authored Aug 18, 2022
1 parent 8a2d58c commit 9a17bb6
Show file tree
Hide file tree
Showing 34 changed files with 288 additions and 252 deletions.
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ updates:
schedule:
interval: "daily"
ignore:
- dependency-name: "go.nhat.io/clock"
- dependency-name: "go.nhat.io/testcontainers-*"
- dependency-name: "go.opentelemetry.io/*"
- dependency-name: "github.com/Masterminds/squirrel"
- dependency-name: "github.com/nhatthm/go-clock"
- dependency-name: "github.com/nhatthm/testcontainers-go-*"
- dependency-name: "github.com/stretchr/testify"

- package-ecosystem: "gomod"
directory: "/tests/mysql"
schedule:
interval: "daily"
ignore:
- dependency-name: "go.nhat.io/clock"
- dependency-name: "go.nhat.io/testcontainers-*"
- dependency-name: "go.opentelemetry.io/*"
- dependency-name: "github.com/Masterminds/squirrel"
- dependency-name: "github.com/nhatthm/go-clock"
- dependency-name: "github.com/nhatthm/testcontainers-go-*"
- dependency-name: "github.com/stretchr/testify"

- package-ecosystem: "gomod"
directory: "/tests/postgres"
schedule:
interval: "daily"
ignore:
- dependency-name: "go.nhat.io/clock"
- dependency-name: "go.nhat.io/testcontainers-*"
- dependency-name: "go.opentelemetry.io/*"
- dependency-name: "github.com/Masterminds/squirrel"
- dependency-name: "github.com/nhatthm/go-clock"
- dependency-name: "github.com/nhatthm/testcontainers-go-*"
- dependency-name: "github.com/stretchr/testify"

- package-ecosystem: "github-actions"
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
schedule:
- cron: '33 10 * * 6'

env:
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -44,6 +47,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
if: ${{ matrix.language == 'go' }}
with:
go-version: ${{ env.GO_VERSION }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
- master

env:
GO_VERSION: 1.17
GOLANGCI_LINT_VERSION: v1.45.0
GO_VERSION: 1.18
GOLANGCI_LINT_VERSION: v1.48.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_LATEST_VERSION: "1.18.x"
GOLANGCI_LINT_VERSION: v1.45.0
GO_VERSION: 1.18
GO_LATEST_VERSION: "1.19.x"
GOLANGCI_LINT_VERSION: v1.48.0

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-compatibility-libpq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ 1.17.x, 1.18.x ]
go-version: [ 1.18.x, 1.19.x ]
arch: [ "386", amd64 ]
postgres-version: [ "12", "13", "14" ]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-compatibility-mssql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ 1.17.x, 1.18.x ]
go-version: [ 1.19.x, 1.19.x ]
arch: [ "386", amd64 ]
mssql-version: [ "2019" ]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-compatibility-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ 1.17.x, 1.18.x ]
go-version: [ 1.18.x, 1.19.x ]
arch: [ "386", amd64 ]
mysql-version: [ "8" ]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-compatibility-pgx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GO111MODULE: "on"
GO_VERSION: 1.17
GO_VERSION: 1.18

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ 1.17.x, 1.18.x ]
go-version: [ 1.18.x, 1.19.x ]
arch: [ "386", amd64 ]
postgres-version: [ "12", "13", "14" ]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GO111MODULE: "on"
GO_LATEST_VERSION: "1.18.x"
GO_LATEST_VERSION: "1.19.x"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go-version: [ 1.17.x, 1.18.x ]
go-version: [ 1.18.x, 1.19.x ]
arch: [ "386", amd64 ]
exclude:
- os: macos-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

bin
# Dependency directories (remove the comment below to include it)
vendor

Expand Down
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ linters:
disable:
- contextcheck
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert
- gci
Expand All @@ -35,6 +36,9 @@ linters:
- ireturn
- lll
- maligned
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- nonamedreturns
- nosnakecase
- paralleltest
- scopelint
- tagliatelle
Expand All @@ -48,6 +52,7 @@ issues:
- linters:
- containedctx
- dupl
- execinquery
- funlen
- goconst
- goerr113
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= v1.48.0

GO ?= go
GOLANGCI_LINT ?= golangci-lint
GHERKIN_LINT ?= gherkin-lint
Expand All @@ -24,11 +26,11 @@ $(VENDOR_DIR):
@$(GO) mod vendor

.PHONY: $(lintGoModules)
$(lintGoModules):
$(lintGoModules): bin/$(GOLANGCI_LINT)
$(eval GO_MODULE := "$(subst lint/module,.,$(subst -,/,$(subst lint-module-,,$@)))")

@echo ">> module: $(GO_MODULE)"
@cd "$(GO_MODULE)"; $(GOLANGCI_LINT) run
@cd "$(GO_MODULE)"; bin/$(GOLANGCI_LINT) run

.PHONY: lint
lint: $(lintGoModules)
Expand Down Expand Up @@ -72,3 +74,8 @@ test-compatibility: $(compatibilityTests)

.PHONY: test
test: test-unit test-compatibility

bin/$(GOLANGCI_LINT):
@echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin "$(GOLANGCI_LINT_VERSION)"
@mv ./bin/golangci-lint bin/$(GOLANGCI_LINT)
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/nhatthm/otelsql

go 1.17
go 1.18

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/stretchr/testify v1.8.0
github.com/swaggest/assertjson v1.7.0
go.opentelemetry.io/otel v1.9.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.31.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0
go.opentelemetry.io/otel/metric v0.31.0
go.opentelemetry.io/otel/sdk v1.8.0
go.opentelemetry.io/otel/sdk v1.9.0
go.opentelemetry.io/otel/sdk/metric v0.31.0
go.opentelemetry.io/otel/trace v1.9.0
)
Expand All @@ -29,7 +29,7 @@ require (
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw=
go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.31.0 h1:fu/wxbXqjgIRZYzQNrF175qtwrJx+oQSFhZpTIbNQLc=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.31.0/go.mod h1:a80IJcYgCLVXJurhoyPjMBiNI5gPrWXLBTAwOp8N6Vw=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0 h1:FVy7BZCjoA2Nk+fHqIdoTmm554J9wTX+YcrDp+mc368=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0/go.mod h1:ztncjvKpotSUQq7rlgPibGt8kZfSI3/jI8EO7JjuY2c=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0 h1:0uV0qzHk48i1SF8qRI8odMYiwPOLh9gBhiJFpj8H6JY=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0/go.mod h1:Fl1iS5ZhWgXXXTdJMuBSVsS5nkL5XluHbg97kjOuYU4=
go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs=
go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A=
go.opentelemetry.io/otel/sdk v1.8.0 h1:xwu69/fNuwbSHWe/0PGS888RmjWY181OmcXDQKu7ZQk=
go.opentelemetry.io/otel/sdk v1.8.0/go.mod h1:uPSfc+yfDH2StDM/Rm35WE8gXSNdvCg023J6HeGNO0c=
go.opentelemetry.io/otel/sdk v1.9.0 h1:LNXp1vrr83fNXTHgU8eO89mhzxb/bbWAsHG6fNf3qWo=
go.opentelemetry.io/otel/sdk v1.9.0/go.mod h1:AEZc8nt5bd2F7BC24J5R0mrjYnpEgYHyTcM/vrSple4=
go.opentelemetry.io/otel/sdk/metric v0.31.0 h1:2sZx4R43ZMhJdteKAlKoHvRgrMp53V1aRxvEf5lCq8Q=
go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk=
go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc=
Expand All @@ -67,8 +67,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacp
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I=
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
21 changes: 11 additions & 10 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,19 @@ func DisableErrSkip() DriverOption {
// TraceQuery sets a custom function that will return a list of attributes to add to the spans with a given query and args.
//
// For example:
// otelsql.TraceQuery(func(sql string, args []driver.NamedValue) []attribute.KeyValue {
// attrs := make([]attribute.KeyValue, 0)
// attrs = append(attrs, semconv.DBStatementKey.String(sql))
//
// for _, arg := range args {
// if arg.Name != "password" {
// attrs = append(attrs, sqlattribute.FromNamedValue(arg))
// }
// }
// otelsql.TraceQuery(func(sql string, args []driver.NamedValue) []attribute.KeyValue {
// attrs := make([]attribute.KeyValue, 0)
// attrs = append(attrs, semconv.DBStatementKey.String(sql))
//
// return attrs
// })
// for _, arg := range args {
// if arg.Name != "password" {
// attrs = append(attrs, sqlattribute.FromNamedValue(arg))
// }
// }
//
// return attrs
// })
func TraceQuery(f queryTracer) DriverOption {
return driverOptionFunc(func(o *driverOptions) {
o.trace.queryTracer = f
Expand Down
Loading

0 comments on commit 9a17bb6

Please sign in to comment.