diff --git a/go.mod b/go.mod index a3f83d7..c69cfdb 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/dustin/go-humanize v1.0.0 github.com/go-co-op/gocron v1.17.1 github.com/go-ozzo/ozzo-validation/v4 v4.3.0 + github.com/go-redis/redis/extra/redisotel/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5 github.com/gofrs/uuid v4.3.0+incompatible github.com/gorilla/mux v1.8.0 @@ -41,7 +42,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-redis/redis/extra/rediscmd/v8 v8.11.5 // indirect - github.com/go-redis/redis/extra/redisotel/v8 v8.11.5 // indirect github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/uuid v1.3.0 // indirect diff --git a/internal/reddit/client.go b/internal/reddit/client.go index 88995e1..ce31271 100644 --- a/internal/reddit/client.go +++ b/internal/reddit/client.go @@ -95,8 +95,13 @@ func NewClient(id, secret string, tracer trace.Tracer, statsd statsd.ClientInter pool.Put(parsers[i]) } + t := http.DefaultTransport.(*http.Transport).Clone() + t.MaxIdleConns = 100 + t.MaxConnsPerHost = 100 + t.MaxIdleConnsPerHost = 100 + httpClient := &http.Client{ - Transport: otelhttp.NewTransport(http.DefaultTransport), + Transport: otelhttp.NewTransport(t), Timeout: 4 * time.Second, } diff --git a/internal/repository/connection.go b/internal/repository/connection.go index 8937d43..5820720 100644 --- a/internal/repository/connection.go +++ b/internal/repository/connection.go @@ -5,7 +5,7 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" - "go.opentelemetry.io/otel/attribute" + semconv "go.opentelemetry.io/otel/semconv/v1.10.0" "go.opentelemetry.io/otel/trace" ) @@ -17,6 +17,6 @@ type Connection interface { func spanWithQuery(ctx context.Context, tracer trace.Tracer, query string) (context.Context, trace.Span) { ctx, span := tracer.Start(ctx, "db:query") - span.SetAttributes(attribute.String("db.query", query)) + span.SetAttributes(semconv.DBStatementKey.String(query)) return ctx, span }