apollo-backend/internal/repository/connection.go

23 lines
628 B
Go
Raw Normal View History

package repository
import (
"context"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4"
2022-11-03 17:43:10 +00:00
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
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-03 17:43:10 +00:00
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))
return ctx, span
}