Skip to content

Commit 2eb04bf

Browse files
committed
Separate interface
1 parent bd4b913 commit 2eb04bf

File tree

8 files changed

+171
-36
lines changed

8 files changed

+171
-36
lines changed

common/metrics/metrics.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ type (
6060

6161
Stop(log.Logger)
6262

63-
// BatchStart returns a Handler that where supported, can emit a series of metrics as a single "wide event".
63+
// StartBatch returns a BatchHandler that can emit a series of metrics as a single "wide event".
6464
// If wide events aren't supported in the underlying implementation, metrics can still be sent individually.
65-
BatchStart(string) (Handler, io.Closer)
65+
StartBatch(string) BatchHandler
66+
}
67+
68+
BatchHandler interface {
69+
Handler
70+
io.Closer
6671
}
6772

6873
// CounterIface is an ever-increasing counter.
@@ -71,7 +76,7 @@ type (
7176
// Tags provided are merged with the source MetricsHandler
7277
Record(int64, ...Tag)
7378
}
74-
// GaugeIface can be set to any float and repesents a latest value instrument.
79+
// GaugeIface can be set to any float and represents a latest value instrument.
7580
GaugeIface interface {
7681
// Record updates the gauge value.
7782
// Tags provided are merged with the source MetricsHandler

common/metrics/metrics_mock.go

Lines changed: 151 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/metrics/metricstest/capture_handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package metricstest
2626

2727
import (
28-
"io"
2928
"sync"
3029
"time"
3130

@@ -147,8 +146,8 @@ func (c *CaptureHandler) Close() error {
147146
return nil
148147
}
149148

150-
func (c *CaptureHandler) BatchStart(_ string) (metrics.Handler, io.Closer) {
151-
return c, c
149+
func (c *CaptureHandler) StartBatch(_ string) metrics.BatchHandler {
150+
return c
152151
}
153152

154153
// Stop implements [metrics.Handler.Stop].

common/metrics/noop_impl.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package metrics
2626

2727
import (
28-
"io"
2928
"time"
3029

3130
"go.temporal.io/server/common/log"
@@ -73,8 +72,8 @@ func (*noopMetricsHandler) Close() error {
7372
return nil
7473
}
7574

76-
func (n *noopMetricsHandler) BatchStart(_ string) (Handler, io.Closer) {
77-
return n, n
75+
func (n *noopMetricsHandler) StartBatch(_ string) BatchHandler {
76+
return n
7877
}
7978

8079
var NoopCounterMetricFunc = CounterFunc(func(i int64, t ...Tag) {})

common/metrics/otel_metrics_handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ package metrics
2727
import (
2828
"context"
2929
"fmt"
30-
"io"
3130
"sync"
3231
"time"
3332

@@ -209,8 +208,8 @@ func (omp *otelMetricsHandler) Close() error {
209208
return nil
210209
}
211210

212-
func (omp *otelMetricsHandler) BatchStart(_ string) (Handler, io.Closer) {
213-
return omp, omp
211+
func (omp *otelMetricsHandler) StartBatch(_ string) BatchHandler {
212+
return omp
214213
}
215214

216215
// makeSet returns an otel attribute.Set with the given tags merged with the

common/metrics/tally_metrics_handler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package metrics
2626

2727
import (
28-
"io"
2928
"time"
3029

3130
"github.com/uber-go/tally/v4"
@@ -125,8 +124,8 @@ func (*tallyMetricsHandler) Close() error {
125124
return nil
126125
}
127126

128-
func (tmh *tallyMetricsHandler) BatchStart(_ string) (Handler, io.Closer) {
129-
return tmh, tmh
127+
func (tmh *tallyMetricsHandler) StartBatch(_ string) BatchHandler {
128+
return tmh
130129
}
131130

132131
func tagsToMap(t1 []Tag, e excludeTags) map[string]string {

service/history/historybuilder/history_builder_categorization_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package historybuilder
2626

2727
import (
28-
"io"
2928
"testing"
3029
"time"
3130

@@ -71,8 +70,8 @@ func (h StubHandler) Close() error {
7170
return nil
7271
}
7372

74-
func (h StubHandler) BatchStart(_ string) (metrics.Handler, io.Closer) {
75-
return h, h
73+
func (h StubHandler) StartBatch(_ string) metrics.BatchHandler {
74+
return h
7675
}
7776

7877
func TestHistoryBuilder_IsDirty(t *testing.T) {

service/history/workflow/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func emitMutableStateStatus(
6161
return
6262
}
6363

64-
batchHandler, closer := metricsHandler.BatchStart("mutable_state_status")
65-
defer closer.Close()
64+
batchHandler := metricsHandler.StartBatch("mutable_state_status")
65+
defer batchHandler.Close()
6666
metrics.MutableStateSize.With(batchHandler).Record(int64(stats.TotalSize))
6767
metrics.ExecutionInfoSize.With(batchHandler).Record(int64(stats.ExecutionInfoSize))
6868
metrics.ExecutionStateSize.With(batchHandler).Record(int64(stats.ExecutionStateSize))

0 commit comments

Comments
 (0)