go

http-tags

This is a low-level package that can be used to prepare SQLCommenterTags out of an http request. The core package can then be used to inject these tags into a context. Installation go get -u github.com/google/sqlcommenter/go/net/http Usage import ( sqlcommenterhttp "github.com/google/sqlcommenter/go/net/http" "github.com/google/sqlcommenter/go/core" ) requestTags := sqlcommenterhttp.NewHTTPRequestTags(framework string, route string, action string) ctx := core.ContextInject(request.Context(), requestTags) requestWithTags := request.WithContext(ctx) This package can be used to instrument SQLCommenter for various frameworks. »

gorrila/mux

This library provides a middleware that extracts SQLCommenter HTTP request tags from a request being handled by gorrila/mux and attaches them to the request’s context. This same context, when used to run queries using sqlcommenter/go/database/sql, allows request tags and traceparent(if using otelmux) to be passed into SQL comments. Installation go get -u github.com/google/sqlcommenter/go/gorrila/mux Usage import ( "net/http" sqlcommentermux "github.com/google/sqlcommenter/go/gorrila/mux" "github.com/gorilla/mux" ) func runApp() { r := mux.NewRouter() r.Use(sqlcommentermux.SQLCommenterMiddleware) r.HandleFunc("/", ActionHome).Methods("GET") http. »

database/sql

SQLCommenter provides drop-in replacement for go’s database/sql library. You can start using the SQLcommenter’s database/sql without changing your business logic code and use one of the framework instrumentation to proapagate tags and traceparent to the SQL queries. Installation go get -u github.com/google/sqlcommenter/go/database/sql Usage Please use the sqlcommenter’s go-sql database driver to open a connection and use that connection to execute statements. Due to inherent nature of Go, the safer way to pass information from framework to database driver is via context. »