Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: cosmos query time (#15006)

Danny Xu31f1f0c58c45
diff --git a/backend/plugin/db/cosmosdb/cosmosdb.go b/backend/plugin/db/cosmosdb/cosmosdb.go
index f154e5b723..312208b7fd 100644
--- a/backend/plugin/db/cosmosdb/cosmosdb.go
+++ b/backend/plugin/db/cosmosdb/cosmosdb.go
@@ -8,9 +8,11 @@ import (
"io"
"log/slog"
"sort"
+ "time"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
+ "google.golang.org/protobuf/types/known/durationpb"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos"
@@ -94,6 +96,7 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement stri
return nil, status.Errorf(codes.InvalidArgument, "container argument is required for CosmosDB")
}
+ startTime := time.Now()
container, err := driver.client.NewContainer(driver.databaseName, queryContext.Container)
if err != nil {
return nil, status.Error(codes.Internal, errors.Wrapf(err, "failed to create container").Error())
@@ -225,6 +228,7 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement stri
Values: values,
})
}
+ result.Latency = durationpb.New(time.Since(startTime))
if illegal {
var rows []*v1pb.QueryRow