Skip to content

Commit 62a512a

Browse files
committed
refactor: Rename timeTransform to timeSub
1 parent 7267a31 commit 62a512a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"go.opentelemetry.io/otel/metric"
1111
)
1212

13-
type timeTransform[T n64] func(start time.Time) T
13+
type timeSub[T n64] func(start time.Time) T
1414

1515
type n64 interface {
1616
int64 | float64

histogram.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ type Histogram[T n64] interface {
2020
// that records the time elapsed since the starting point. The returned
2121
// function may also receive record options to further support information
2222
// that may vary along a given procedure.
23-
Measure(transform timeTransform[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption)
23+
Measure(sub timeSub[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption)
2424

2525
// MeasureCtx creates a starting point using time.Now and returns a function
2626
// that records the time elapsed since the starting point. The returned
2727
// function may also receive record options to further support information
2828
// that may vary along a given procedure.
29-
MeasureCtx(ctx context.Context, transform timeTransform[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption)
29+
MeasureCtx(ctx context.Context, sub timeSub[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption)
3030
}
3131

3232
type histogram[T n64] struct {
@@ -42,15 +42,15 @@ func (h *histogram[T]) RecordCtx(ctx context.Context, n T, opts ...metric.Record
4242
h.baseRecord.Record(ctx, n, append(opts, metric.WithAttributes(h.attrs...))...)
4343
}
4444

45-
func (h *histogram[T]) Measure(transform timeTransform[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption) {
46-
return h.MeasureCtx(context.Background(), transform, opts...)
45+
func (h *histogram[T]) Measure(sub timeSub[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption) {
46+
return h.MeasureCtx(context.Background(), sub, opts...)
4747
}
4848

49-
func (h *histogram[T]) MeasureCtx(ctx context.Context, transform timeTransform[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption) {
50-
now := time.Now()
49+
func (h *histogram[T]) MeasureCtx(ctx context.Context, sub timeSub[T], opts ...metric.RecordOption) func(opts ...metric.RecordOption) {
50+
start := time.Now()
5151
baseOpts := opts
5252
return func(opts ...metric.RecordOption) {
53-
h.RecordCtx(ctx, transform(now), append(baseOpts, opts...)...)
53+
h.RecordCtx(ctx, sub(start), append(baseOpts, opts...)...)
5454
}
5555
}
5656

0 commit comments

Comments
 (0)