Skip to content

Commit 441ac40

Browse files
committed
refactor: rename to completed
1 parent 94afcde commit 441ac40

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

go.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ type (
2727
// telemetry
2828
meter metric.Meter
2929
tracer trace.Tracer
30-
totalCounter metric.Int64Counter
31-
totalCounterName string
3230
runningCounter metric.Int64UpDownCounter
3331
runningCounterName string
32+
completedCounter metric.Int64Counter
33+
completedCounterName string
3434
durationHistogram metric.Int64Histogram
3535
durationHistogramName string
3636
durationHistogramEnabled bool
@@ -75,9 +75,9 @@ func WithTracer(v trace.Tracer) Option {
7575
}
7676
}
7777

78-
func WithTotalCounterName(name string) Option {
78+
func WithCompletedCounterName(name string) Option {
7979
return func(o *Options) {
80-
o.totalCounterName = name
80+
o.completedCounterName = name
8181
}
8282
}
8383

@@ -103,8 +103,8 @@ func Go(fn Func, opts ...Option) <-chan error {
103103
o := &Options{
104104
l: zap.NewNop(),
105105
level: zapcore.DebugLevel,
106-
totalCounterName: "gofuncy.routine.total.count",
107106
runningCounterName: "gofuncy.routine.running.count",
107+
completedCounterName: "gofuncy.routine.completed.count",
108108
durationHistogramName: "gofuncy.routine.duration",
109109
telemetryEnabled: os.Getenv("OTEL_ENABLED") == "true",
110110
}
@@ -135,14 +135,6 @@ func Go(fn Func, opts ...Option) <-chan error {
135135
}
136136
}
137137
if o.meter != nil {
138-
if value, err := o.meter.Int64Counter(
139-
o.totalCounterName,
140-
metric.WithDescription("Gofuncy total go routine count"),
141-
); err != nil {
142-
o.l.Error("failed to initialize counter", zap.Error(err))
143-
} else {
144-
o.totalCounter = value
145-
}
146138
if value, err := o.meter.Int64UpDownCounter(
147139
o.runningCounterName,
148140
metric.WithDescription("Gofuncy running go routine count"),
@@ -151,6 +143,14 @@ func Go(fn Func, opts ...Option) <-chan error {
151143
} else {
152144
o.runningCounter = value
153145
}
146+
if value, err := o.meter.Int64Counter(
147+
o.completedCounterName,
148+
metric.WithDescription("Gofuncy completed go routine count"),
149+
); err != nil {
150+
o.l.Error("failed to initialize counter", zap.Error(err))
151+
} else {
152+
o.completedCounter = value
153+
}
154154
}
155155
if o.meter != nil && o.durationHistogramEnabled {
156156
if value, err := o.meter.Int64Histogram(
@@ -197,8 +197,8 @@ func Go(fn Func, opts ...Option) <-chan error {
197197
o.runningCounter.Add(ctx, 1, attrs)
198198
defer o.runningCounter.Add(ctx, -1, attrs)
199199
}
200-
if o.totalCounter != nil {
201-
o.totalCounter.Add(ctx, 1, attrs)
200+
if o.completedCounter != nil {
201+
o.completedCounter.Add(ctx, 1, attrs)
202202
defer o.runningCounter.Add(ctx, -1, attrs, metric.WithAttributes(
203203
attribute.Bool("error", err != nil),
204204
))

0 commit comments

Comments
 (0)