2022-05-07 16:37:21 +00:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-24 17:12:09 +00:00
|
|
|
"github.com/jackc/pgx/v5"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
2022-11-05 20:08:00 +00:00
|
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
|
2022-11-05 19:59:33 +00:00
|
|
|
"go.opentelemetry.io/otel/trace"
|
2022-05-07 16:37:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Connection interface {
|
|
|
|
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
|
|
|
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
|
|
|
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
|
|
|
}
|
2022-11-05 19:59:33 +00:00
|
|
|
|
|
|
|
func spanWithQuery(ctx context.Context, tracer trace.Tracer, query string) (context.Context, trace.Span) {
|
|
|
|
ctx, span := tracer.Start(ctx, "db:query")
|
2022-11-05 20:08:00 +00:00
|
|
|
span.SetAttributes(semconv.DBStatementKey.String(query))
|
2022-11-05 19:59:33 +00:00
|
|
|
return ctx, span
|
|
|
|
}
|