Skip to content

Commit

Permalink
Tag metric tracking custom order by with namespace (#4344)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed May 15, 2023
1 parent 6eba60d commit fcebf69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,12 @@ func (s *visibilityStore) buildSearchParametersV2(
return nil, serviceerror.NewInvalidArgument("ORDER BY clause is not supported")
}

if len(fieldSorts) > 0 {
// If fieldSorts is not empty, then it's using custom order by.
s.metricsHandler.WithTags(metrics.NamespaceTag(request.Namespace.String())).
Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Record(1)
}

params := &client.SearchParameters{
Index: s.index,
Query: boolQuery,
Expand Down Expand Up @@ -735,7 +741,6 @@ func (s *visibilityStore) setDefaultFieldSort(fieldSorts []*elastic.FieldSort) [
return defaultSorter
}

s.metricsHandler.Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Record(1)
res := make([]elastic.Sorter, len(fieldSorts)+1)
for i, fs := range fieldSorts {
res[i] = fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ func (s *ESVisibilitySuite) TestBuildSearchParametersV2() {
// test custom sort
request.Query = `Order bY WorkflowId`
boolQuery = elastic.NewBoolQuery().Filter(matchNamespaceQuery).MustNot(namespaceDivisionExists)
s.mockMetricsHandler.EXPECT().WithTags(metrics.NamespaceTag(request.Namespace.String())).Return(s.mockMetricsHandler)
s.mockMetricsHandler.EXPECT().Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Return(metrics.NoopCounterMetricFunc)
p, err = s.visibilityStore.buildSearchParametersV2(request)
s.NoError(err)
Expand Down

0 comments on commit fcebf69

Please sign in to comment.