Skip to content

Commit

Permalink
Add a few spans
Browse files Browse the repository at this point in the history
Signed-off-by: sashayakovtseva <[email protected]>
  • Loading branch information
sashayakovtseva committed Mar 1, 2024
1 parent 830b096 commit f6d5fa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/datastore/ydb/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func executeDeleteQuery(
deleteRev revisions.TimestampRevision,
pred sq.Sqlizer,
) error {
ctx, span := tracer.Start(ctx, "executeDeleteQuery")
defer span.End()

return executeQuery(
ctx,
tablePathPrefix,
Expand All @@ -305,6 +308,9 @@ func executeDeleteQuery(

// executeQuery is a helper for queries that don't care about result set.
func executeQuery(ctx context.Context, tablePathPrefix string, executor queryExecutor, q sq.Yqliser) error {
ctx, span := tracer.Start(ctx, "executeQuery")
defer span.End()

sql, args, err := q.ToYQL()
if err != nil {
return fmt.Errorf("failed to build query: %w", err)
Expand Down
7 changes: 6 additions & 1 deletion internal/datastore/ydb/readwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/jzelinskie/stringz"
"github.com/ydb-platform/ydb-go-sdk/v3/table"
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"google.golang.org/protobuf/proto"

Expand Down Expand Up @@ -302,7 +303,8 @@ func (rw *ydbReadWriter) selectTuples(
ctx context.Context,
in []*core.RelationTuple,
) ([]*core.RelationTuple, error) {
span := trace.SpanFromContext(ctx)
ctx, span := tracer.Start(ctx, "selectTuples", trace.WithAttributes(attribute.Int("count", len(in))))
defer span.End()

if len(in) == 0 {
return nil, nil
Expand Down Expand Up @@ -339,6 +341,9 @@ func writeDefinitions[T coreDefinition](
defs []T,
useVT bool,
) error {
ctx, span := tracer.Start(ctx, "writeDefinitions", trace.WithAttributes(attribute.Int("count", len(defs))))
defer span.End()

if len(defs) == 0 {
return nil
}
Expand Down

0 comments on commit f6d5fa8

Please sign in to comment.