Skip to content

Commit

Permalink
log query execution and elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Sep 30, 2019
1 parent cc3bd6f commit cf95cd0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions models/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ func ContactIDsFromReferences(ctx context.Context, tx Queryer, org *OrgAssets, r

// ContactIDsForQuery returns the ids of all the contacts that match the passed in query
func ContactIDsForQuery(ctx context.Context, client *elastic.Client, org *OrgAssets, query string) ([]ContactID, error) {
start := time.Now()

if client == nil {
return nil, errors.Errorf("no elastic client available, check your configuration")
}
Expand Down Expand Up @@ -182,6 +184,13 @@ func ContactIDsForQuery(ctx context.Context, client *elastic.Client, org *OrgAss
for {
results, err := scroll.Do(ctx)
if err == io.EOF {
logrus.WithFields(logrus.Fields{
"org_id": org.OrgID(),
"query": query,
"elapsed": time.Since(start),
"match_count": len(ids),
}).Debug("contact query complete")

return ids, nil
}
if err != nil {
Expand Down

0 comments on commit cf95cd0

Please sign in to comment.