From a2f825a32e5e0e15f59a9c7aee4f871aeda9c2b4 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Tue, 26 May 2020 17:18:23 -0500 Subject: [PATCH 1/3] added some context to tracing --- api.go | 11 ++++++++++- executor.go | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 77a3fc34e..eb1587a13 100644 --- a/api.go +++ b/api.go @@ -1009,6 +1009,9 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp if err != nil { return errors.Wrap(err, "getting index and field") } + span.LogKV( + "index", req.Index, + "field", req.Field) // Unless explicitly ignoring key validation (meaning keys have been // translated to ids in a previous step at the coordinator node), then @@ -1016,6 +1019,7 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp if !options.IgnoreKeyCheck { // Translate row keys. if field.Keys() { + span.LogKV("row_keys", true) if len(req.RowIDs) != 0 { return errors.New("row ids cannot be used because field uses string keys") } @@ -1026,6 +1030,7 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp // Translate column keys. if index.Keys() { + span.LogKV("column_keys", true) if len(req.ColumnIDs) != 0 { return errors.New("column ids cannot be used because index uses string keys") } @@ -1124,13 +1129,16 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest, opts . if err != nil { return errors.Wrap(err, "getting index and field") } - + span.LogKV( + "index", req.Index, + "field", req.Field) // Unless explicitly ignoring key validation (meaning keys have been // translate to ids in a previous step at the coordinator node), then // check to see if keys need translation. if !options.IgnoreKeyCheck { // Translate column keys. if index.Keys() { + span.LogKV("column_keys", true) if len(req.ColumnIDs) != 0 { return errors.New("column ids cannot be used because index uses string keys") } @@ -1144,6 +1152,7 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest, opts . // the field has a ForeignIndex with keys). if field.Keys() { // Perform translation. + span.LogKV("row_keys", true) uints, err := api.cluster.translateIndexKeys(ctx, field.ForeignIndex(), req.StringValues) if err != nil { return err diff --git a/executor.go b/executor.go index 3aa677c44..a26dd2fb2 100644 --- a/executor.go +++ b/executor.go @@ -155,6 +155,7 @@ func (e *executor) registerOps(ops []ext.BitmapOp) error { // Execute executes a PQL query. func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shards []uint64, opt *execOptions) (QueryResponse, error) { span, ctx := tracing.StartSpanFromContext(ctx, "Executor.Execute") + span.LogKV("pql", q.String()) defer span.Finish() resp := QueryResponse{} @@ -1124,6 +1125,7 @@ func (e *executor) executePrecomputedCall(ctx context.Context, index string, c * // executeBitmapCall executes a call that returns a bitmap. func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (*Row, error) { span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCall") + span.LogKV("pql_call_name", c.Name) defer span.Finish() indexTag := "index:" + index @@ -1206,6 +1208,7 @@ func (e *executor) executeBitmapCallShard(ctx context.Context, index string, c * } span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCallShard") + span.LogKV("pql_call_name", c.Name) defer span.Finish() if _, ok := e.additionalCountOps[c.Name]; ok { From 022019c6cc6828756ffbbd10673888bc2cdb21a2 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Tue, 26 May 2020 23:23:57 -0500 Subject: [PATCH 2/3] removed shard level tracing tag --- executor.go | 1 - 1 file changed, 1 deletion(-) diff --git a/executor.go b/executor.go index a26dd2fb2..b8147a64c 100644 --- a/executor.go +++ b/executor.go @@ -1208,7 +1208,6 @@ func (e *executor) executeBitmapCallShard(ctx context.Context, index string, c * } span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCallShard") - span.LogKV("pql_call_name", c.Name) defer span.Finish() if _, ok := e.additionalCountOps[c.Name]; ok { From 4274d2d1418a1cc2967be22802b9b17b55400bd6 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 27 May 2020 15:23:13 -0500 Subject: [PATCH 3/3] convert to camelCase --- api.go | 8 ++++---- executor.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.go b/api.go index eb1587a13..90d3e2e96 100644 --- a/api.go +++ b/api.go @@ -1019,7 +1019,7 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp if !options.IgnoreKeyCheck { // Translate row keys. if field.Keys() { - span.LogKV("row_keys", true) + span.LogKV("rowKeys", true) if len(req.RowIDs) != 0 { return errors.New("row ids cannot be used because field uses string keys") } @@ -1030,7 +1030,7 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp // Translate column keys. if index.Keys() { - span.LogKV("column_keys", true) + span.LogKV("columnKeys", true) if len(req.ColumnIDs) != 0 { return errors.New("column ids cannot be used because index uses string keys") } @@ -1138,7 +1138,7 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest, opts . if !options.IgnoreKeyCheck { // Translate column keys. if index.Keys() { - span.LogKV("column_keys", true) + span.LogKV("columnKeys", true) if len(req.ColumnIDs) != 0 { return errors.New("column ids cannot be used because index uses string keys") } @@ -1152,7 +1152,7 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest, opts . // the field has a ForeignIndex with keys). if field.Keys() { // Perform translation. - span.LogKV("row_keys", true) + span.LogKV("rowKeys", true) uints, err := api.cluster.translateIndexKeys(ctx, field.ForeignIndex(), req.StringValues) if err != nil { return err diff --git a/executor.go b/executor.go index b8147a64c..23c0835f6 100644 --- a/executor.go +++ b/executor.go @@ -1125,7 +1125,7 @@ func (e *executor) executePrecomputedCall(ctx context.Context, index string, c * // executeBitmapCall executes a call that returns a bitmap. func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.Call, shards []uint64, opt *execOptions) (*Row, error) { span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeBitmapCall") - span.LogKV("pql_call_name", c.Name) + span.LogKV("pqlCallName", c.Name) defer span.Finish() indexTag := "index:" + index