From 7549efbf6e15b0203e1f1425cf2cd4bd52aecab4 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 13:28:33 +0300 Subject: [PATCH 1/6] add sqlcomment to sql.conn.query span --- conn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conn.go b/conn.go index 10e1b0c..7c7ecc7 100644 --- a/conn.go +++ b/conn.go @@ -136,6 +136,7 @@ func (c *otConn) QueryContext( onDefer(err) }() + query = c.cfg.SQLCommenter.withComment(ctx, query) var span trace.Span queryCtx := ctx if !c.cfg.SpanOptions.OmitConnQuery && filterSpan(ctx, c.cfg.SpanOptions, method, query, args) { @@ -143,7 +144,7 @@ func (c *otConn) QueryContext( defer span.End() } - rows, err = queryer.QueryContext(queryCtx, c.cfg.SQLCommenter.withComment(queryCtx, query), args) + rows, err = queryer.QueryContext(queryCtx, query, args) if err != nil { recordSpanError(span, c.cfg.SpanOptions, err) return nil, err From b045aed5750c87694661e50b64d152dd66891f1f Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 13:51:58 +0300 Subject: [PATCH 2/6] fix go.mod --- example_test.go | 2 +- go.mod | 5 +++-- go.sum | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example_test.go b/example_test.go index b7e7321..a9dab01 100644 --- a/example_test.go +++ b/example_test.go @@ -18,7 +18,7 @@ import ( "database/sql" "database/sql/driver" - "github.com/XSAM/otelsql" + "github.com/LeonPev/otelsql" ) func init() { diff --git a/go.mod b/go.mod index ead645f..53186d2 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,9 @@ -module github.com/XSAM/otelsql +module github.com/LeonPev/otelsql -go 1.19 +go 1.20 require ( + github.com/XSAM/otelsql v0.23.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 diff --git a/go.sum b/go.sum index 6dc5ba4..02cc4be 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/XSAM/otelsql v0.23.0 h1:NsJQS9YhI1+RDsFqE9mW5XIQmPmdF/qa8qQOLZN8XEA= +github.com/XSAM/otelsql v0.23.0/go.mod h1:oX4LXMsb+9lAZhvHjUS61oQP/hbcJRadWHnBKNL+LuM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= From ddfc2a373d8fcd341aed93cfbfc46d5f602892c6 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 14:11:43 +0300 Subject: [PATCH 3/6] fix go.mod --- example/go.mod | 6 +++--- example/main.go | 4 ++-- go.mod | 1 - go.sum | 2 -- internal/tools/go.mod | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/example/go.mod b/example/go.mod index baf6f5b..25b9d88 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,11 +1,11 @@ -module github.com/XSAM/otelsql/example +module github.com/LeoPev/otelsql/example go 1.19 -replace github.com/XSAM/otelsql => ../ +replace github.com/LeoPev/otelsql => ../ require ( - github.com/XSAM/otelsql v0.0.0 + github.com/LeoPev/otelsql v0.0.0 github.com/go-sql-driver/mysql v1.7.1 github.com/prometheus/client_golang v1.15.1 go.opentelemetry.io/otel v1.16.0 diff --git a/example/main.go b/example/main.go index 735ed48..b8141d2 100644 --- a/example/main.go +++ b/example/main.go @@ -22,6 +22,8 @@ import ( "net/http" "time" + "github.com/LeonPev/otelsql" + _ "github.com/go-sql-driver/mysql" "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel" @@ -31,8 +33,6 @@ import ( "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.18.0" - - "github.com/XSAM/otelsql" ) const instrumentationName = "github.com/XSAM/otelsql/example" diff --git a/go.mod b/go.mod index 53186d2..a8ce064 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/LeonPev/otelsql go 1.20 require ( - github.com/XSAM/otelsql v0.23.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 diff --git a/go.sum b/go.sum index 02cc4be..6dc5ba4 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/XSAM/otelsql v0.23.0 h1:NsJQS9YhI1+RDsFqE9mW5XIQmPmdF/qa8qQOLZN8XEA= -github.com/XSAM/otelsql v0.23.0/go.mod h1:oX4LXMsb+9lAZhvHjUS61oQP/hbcJRadWHnBKNL+LuM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 66bb7c6..5c6d7d8 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -1,4 +1,4 @@ -module github.com/XSAM/otelsql/internal/tools +module github.com/LeonPev/otelsql/internal/tools go 1.19 From f3fd228ec03cc0247dcf71fb5c393f38e8be8526 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 15:30:31 +0300 Subject: [PATCH 4/6] fixes for tests --- example/main.go | 2 +- example_test.go | 2 +- go.mod | 2 +- internal/tools/go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/main.go b/example/main.go index b8141d2..cf962f8 100644 --- a/example/main.go +++ b/example/main.go @@ -22,7 +22,7 @@ import ( "net/http" "time" - "github.com/LeonPev/otelsql" + "github.com/XSAM/otelsql" _ "github.com/go-sql-driver/mysql" "github.com/prometheus/client_golang/prometheus/promhttp" diff --git a/example_test.go b/example_test.go index a9dab01..b7e7321 100644 --- a/example_test.go +++ b/example_test.go @@ -18,7 +18,7 @@ import ( "database/sql" "database/sql/driver" - "github.com/LeonPev/otelsql" + "github.com/XSAM/otelsql" ) func init() { diff --git a/go.mod b/go.mod index a8ce064..ea975d1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/LeonPev/otelsql +module github.com/XSAM/otelsql go 1.20 diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 5c6d7d8..66bb7c6 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -1,4 +1,4 @@ -module github.com/LeonPev/otelsql/internal/tools +module github.com/XSAM/otelsql/internal/tools go 1.19 From 6664521c80c160c84fbb04684f27464db57fa0e8 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 15:34:27 +0300 Subject: [PATCH 5/6] fixes for tests --- example/go.mod | 6 +++--- example/main.go | 1 - go.mod | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/example/go.mod b/example/go.mod index 25b9d88..baf6f5b 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,11 +1,11 @@ -module github.com/LeoPev/otelsql/example +module github.com/XSAM/otelsql/example go 1.19 -replace github.com/LeoPev/otelsql => ../ +replace github.com/XSAM/otelsql => ../ require ( - github.com/LeoPev/otelsql v0.0.0 + github.com/XSAM/otelsql v0.0.0 github.com/go-sql-driver/mysql v1.7.1 github.com/prometheus/client_golang v1.15.1 go.opentelemetry.io/otel v1.16.0 diff --git a/example/main.go b/example/main.go index cf962f8..dd7cfa3 100644 --- a/example/main.go +++ b/example/main.go @@ -23,7 +23,6 @@ import ( "time" "github.com/XSAM/otelsql" - _ "github.com/go-sql-driver/mysql" "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel" diff --git a/go.mod b/go.mod index ea975d1..ead645f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/XSAM/otelsql -go 1.20 +go 1.19 require ( github.com/stretchr/testify v1.8.4 From ab7f8ba2ee0c2aa7cd00a5c9d1dc1bfb63c3ab35 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 16 Jun 2023 15:35:08 +0300 Subject: [PATCH 6/6] fixes for tests --- example/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/main.go b/example/main.go index dd7cfa3..735ed48 100644 --- a/example/main.go +++ b/example/main.go @@ -22,7 +22,6 @@ import ( "net/http" "time" - "github.com/XSAM/otelsql" _ "github.com/go-sql-driver/mysql" "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel" @@ -32,6 +31,8 @@ import ( "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.18.0" + + "github.com/XSAM/otelsql" ) const instrumentationName = "github.com/XSAM/otelsql/example"