Skip to content

Commit

Permalink
Add counter to track custom order by usage in Elasticsearch (#4064)
Browse files Browse the repository at this point in the history
Add counter to track custom order by usage
  • Loading branch information
rodrigozhou authored Mar 21, 2023
1 parent 4033f21 commit e7b4276
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/metrics/metric_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ var (
ElasticsearchBulkProcessorBulkSize = NewDimensionlessHistogramDef("elasticsearch_bulk_processor_bulk_size")
ElasticsearchDocumentParseFailuresCount = NewCounterDef("elasticsearch_document_parse_failures_counter")
ElasticsearchDocumentGenerateFailuresCount = NewCounterDef("elasticsearch_document_generate_failures_counter")
ElasticsearchCustomOrderByClauseCount = NewCounterDef("elasticsearch_custom_order_by_clause_counter")
CatchUpReadyShardCountGauge = NewGaugeDef("catchup_ready_shard_count")
HandoverReadyShardCountGauge = NewGaugeDef("handover_ready_shard_count")
ReplicatorMessages = NewCounterDef("replicator_messages")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ 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().Counter(metrics.ElasticsearchCustomOrderByClauseCount.GetMetricName()).Return(metrics.NoopCounterMetricFunc)
p, err = s.visibilityStore.buildSearchParametersV2(request)
s.NoError(err)
s.Equal(&client.SearchParameters{
Expand Down

0 comments on commit e7b4276

Please sign in to comment.