@@ -22,6 +22,7 @@ package pinotvisibility
2222
2323import (
2424 "context"
25+ "time"
2526
2627 "github.com/uber/cadence/common/log"
2728 "github.com/uber/cadence/common/log/tag"
@@ -59,8 +60,12 @@ func (p *pinotVisibilityMetricsClient) RecordWorkflowExecutionStarted(
5960 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotRecordWorkflowExecutionStartedScope , metrics .DomainTag (request .Domain ))
6061 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
6162
63+ pinotStart := time .Now ()
6264 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
63- defer sw .Stop ()
65+ defer func () {
66+ sw .Stop ()
67+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
68+ }()
6469 err := p .persistence .RecordWorkflowExecutionStarted (ctx , request )
6570
6671 if err != nil {
@@ -78,8 +83,12 @@ func (p *pinotVisibilityMetricsClient) RecordWorkflowExecutionClosed(
7883 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotRecordWorkflowExecutionClosedScope , metrics .DomainTag (request .Domain ))
7984 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
8085
86+ pinotStart := time .Now ()
8187 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
82- defer sw .Stop ()
88+ defer func () {
89+ sw .Stop ()
90+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
91+ }()
8392 err := p .persistence .RecordWorkflowExecutionClosed (ctx , request )
8493
8594 if err != nil {
@@ -97,8 +106,12 @@ func (p *pinotVisibilityMetricsClient) RecordWorkflowExecutionUninitialized(
97106 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotRecordWorkflowExecutionUninitializedScope , metrics .DomainTag (request .Domain ))
98107 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
99108
109+ pinotStart := time .Now ()
100110 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
101- defer sw .Stop ()
111+ defer func () {
112+ sw .Stop ()
113+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
114+ }()
102115 err := p .persistence .RecordWorkflowExecutionUninitialized (ctx , request )
103116
104117 if err != nil {
@@ -116,8 +129,12 @@ func (p *pinotVisibilityMetricsClient) UpsertWorkflowExecution(
116129 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotUpsertWorkflowExecutionScope , metrics .DomainTag (request .Domain ))
117130 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
118131
132+ pinotStart := time .Now ()
119133 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
120- defer sw .Stop ()
134+ defer func () {
135+ sw .Stop ()
136+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
137+ }()
121138 err := p .persistence .UpsertWorkflowExecution (ctx , request )
122139
123140 if err != nil {
@@ -135,8 +152,12 @@ func (p *pinotVisibilityMetricsClient) ListOpenWorkflowExecutions(
135152 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListOpenWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
136153 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
137154
155+ pinotStart := time .Now ()
138156 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
139- defer sw .Stop ()
157+ defer func () {
158+ sw .Stop ()
159+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
160+ }()
140161 response , err := p .persistence .ListOpenWorkflowExecutions (ctx , request )
141162
142163 if err != nil {
@@ -154,8 +175,12 @@ func (p *pinotVisibilityMetricsClient) ListClosedWorkflowExecutions(
154175 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListClosedWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
155176 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
156177
178+ pinotStart := time .Now ()
157179 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
158- defer sw .Stop ()
180+ defer func () {
181+ sw .Stop ()
182+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
183+ }()
159184 response , err := p .persistence .ListClosedWorkflowExecutions (ctx , request )
160185
161186 if err != nil {
@@ -173,8 +198,12 @@ func (p *pinotVisibilityMetricsClient) ListOpenWorkflowExecutionsByType(
173198 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListOpenWorkflowExecutionsByTypeScope , metrics .DomainTag (request .Domain ))
174199 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
175200
201+ pinotStart := time .Now ()
176202 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
177- defer sw .Stop ()
203+ defer func () {
204+ sw .Stop ()
205+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
206+ }()
178207 response , err := p .persistence .ListOpenWorkflowExecutionsByType (ctx , request )
179208
180209 if err != nil {
@@ -191,8 +220,12 @@ func (p *pinotVisibilityMetricsClient) ListClosedWorkflowExecutionsByType(
191220
192221 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListClosedWorkflowExecutionsByTypeScope , metrics .DomainTag (request .Domain ))
193222 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
223+ pinotStart := time .Now ()
194224 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
195- defer sw .Stop ()
225+ defer func () {
226+ sw .Stop ()
227+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
228+ }()
196229 response , err := p .persistence .ListClosedWorkflowExecutionsByType (ctx , request )
197230
198231 if err != nil {
@@ -209,8 +242,12 @@ func (p *pinotVisibilityMetricsClient) ListOpenWorkflowExecutionsByWorkflowID(
209242
210243 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListOpenWorkflowExecutionsByWorkflowIDScope , metrics .DomainTag (request .Domain ))
211244 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
245+ pinotStart := time .Now ()
212246 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
213- defer sw .Stop ()
247+ defer func () {
248+ sw .Stop ()
249+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
250+ }()
214251 response , err := p .persistence .ListOpenWorkflowExecutionsByWorkflowID (ctx , request )
215252
216253 if err != nil {
@@ -227,8 +264,12 @@ func (p *pinotVisibilityMetricsClient) ListClosedWorkflowExecutionsByWorkflowID(
227264
228265 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListClosedWorkflowExecutionsByWorkflowIDScope , metrics .DomainTag (request .Domain ))
229266 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
267+ pinotStart := time .Now ()
230268 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
231- defer sw .Stop ()
269+ defer func () {
270+ sw .Stop ()
271+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
272+ }()
232273 response , err := p .persistence .ListClosedWorkflowExecutionsByWorkflowID (ctx , request )
233274
234275 if err != nil {
@@ -245,8 +286,12 @@ func (p *pinotVisibilityMetricsClient) ListClosedWorkflowExecutionsByStatus(
245286
246287 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListClosedWorkflowExecutionsByStatusScope , metrics .DomainTag (request .Domain ))
247288 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
289+ pinotStart := time .Now ()
248290 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
249- defer sw .Stop ()
291+ defer func () {
292+ sw .Stop ()
293+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
294+ }()
250295 response , err := p .persistence .ListClosedWorkflowExecutionsByStatus (ctx , request )
251296
252297 if err != nil {
@@ -263,8 +308,12 @@ func (p *pinotVisibilityMetricsClient) GetClosedWorkflowExecution(
263308
264309 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotGetClosedWorkflowExecutionScope , metrics .DomainTag (request .Domain ))
265310 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
311+ pinotStart := time .Now ()
266312 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
267- defer sw .Stop ()
313+ defer func () {
314+ sw .Stop ()
315+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
316+ }()
268317 response , err := p .persistence .GetClosedWorkflowExecution (ctx , request )
269318
270319 if err != nil {
@@ -281,8 +330,12 @@ func (p *pinotVisibilityMetricsClient) ListWorkflowExecutions(
281330
282331 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotListWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
283332 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
333+ pinotStart := time .Now ()
284334 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
285- defer sw .Stop ()
335+ defer func () {
336+ sw .Stop ()
337+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
338+ }()
286339 response , err := p .persistence .ListWorkflowExecutions (ctx , request )
287340
288341 if err != nil {
@@ -299,8 +352,12 @@ func (p *pinotVisibilityMetricsClient) ScanWorkflowExecutions(
299352
300353 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotScanWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
301354 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
355+ pinotStart := time .Now ()
302356 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
303- defer sw .Stop ()
357+ defer func () {
358+ sw .Stop ()
359+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
360+ }()
304361 response , err := p .persistence .ScanWorkflowExecutions (ctx , request )
305362
306363 if err != nil {
@@ -317,8 +374,12 @@ func (p *pinotVisibilityMetricsClient) CountWorkflowExecutions(
317374
318375 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotCountWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
319376 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
377+ pinotStart := time .Now ()
320378 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
321- defer sw .Stop ()
379+ defer func () {
380+ sw .Stop ()
381+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
382+ }()
322383 response , err := p .persistence .CountWorkflowExecutions (ctx , request )
323384
324385 if err != nil {
@@ -335,8 +396,12 @@ func (p *pinotVisibilityMetricsClient) DeleteWorkflowExecution(
335396
336397 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotDeleteWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
337398 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
399+ pinotStart := time .Now ()
338400 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
339- defer sw .Stop ()
401+ defer func () {
402+ sw .Stop ()
403+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
404+ }()
340405 err := p .persistence .DeleteWorkflowExecution (ctx , request )
341406
342407 if err != nil {
@@ -353,8 +418,12 @@ func (p *pinotVisibilityMetricsClient) DeleteUninitializedWorkflowExecution(
353418
354419 scopeWithDomainTag := p .metricClient .Scope (metrics .PinotDeleteWorkflowExecutionsScope , metrics .DomainTag (request .Domain ))
355420 scopeWithDomainTag .IncCounter (metrics .PinotRequestsPerDomain )
421+ pinotStart := time .Now ()
356422 sw := scopeWithDomainTag .StartTimer (metrics .PinotLatencyPerDomain )
357- defer sw .Stop ()
423+ defer func () {
424+ sw .Stop ()
425+ scopeWithDomainTag .RecordHistogramDuration (metrics .PinotLatencyPerDomainHistogram , time .Since (pinotStart ))
426+ }()
358427 err := p .persistence .DeleteWorkflowExecution (ctx , request )
359428
360429 if err != nil {
0 commit comments