Skip to content

Commit d62fc3a

Browse files
authored
[Metrics] Histogram for deadline remaining on Append (#737)
In sigstore/rekor-tiles#434 it is reported that there are deadline exceeded errors. This could be Tessera taking longer than expected, or it could be clients calling this with unreasonably short deadlines. This histogram metric should give some insight into the spectrum of deadlines that clients are expecting Tessera to work with.
1 parent db473c7 commit d62fc3a

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

append_lifecycle.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ const (
5151
)
5252

5353
var (
54-
appenderAddsTotal metric.Int64Counter
55-
appenderAddHistogram metric.Int64Histogram
56-
appenderHighestIndex metric.Int64Gauge
57-
appenderIntegratedSize metric.Int64Gauge
58-
appenderIntegrateLatency metric.Int64Histogram
59-
appenderNextIndex metric.Int64Gauge
60-
appenderSignedSize metric.Int64Gauge
61-
appenderWitnessedSize metric.Int64Gauge
62-
appenderWitnessRequests metric.Int64Counter
54+
appenderAddsTotal metric.Int64Counter
55+
appenderAddHistogram metric.Int64Histogram
56+
appenderHighestIndex metric.Int64Gauge
57+
appenderIntegratedSize metric.Int64Gauge
58+
appenderIntegrateLatency metric.Int64Histogram
59+
appenderDeadlineRemaining metric.Int64Histogram
60+
appenderNextIndex metric.Int64Gauge
61+
appenderSignedSize metric.Int64Gauge
62+
appenderWitnessedSize metric.Int64Gauge
63+
appenderWitnessRequests metric.Int64Counter
6364

6465
followerEntriesProcessed metric.Int64Gauge
6566
followerLag metric.Int64Gauge
@@ -112,6 +113,15 @@ func init() {
112113
klog.Exitf("Failed to create appenderIntegrateLatency metric: %v", err)
113114
}
114115

116+
appenderDeadlineRemaining, err = meter.Int64Histogram(
117+
"tessera.appender.deadline.remaining",
118+
metric.WithDescription("Duration remaining before context cancellation when appender is invoked (only set for contexts with deadline)"),
119+
metric.WithUnit("ms"),
120+
metric.WithExplicitBucketBoundaries(histogramBuckets...))
121+
if err != nil {
122+
klog.Exitf("Failed to create appenderDeadlineRemaining metric: %v", err)
123+
}
124+
115125
appenderNextIndex, err = meter.Int64Gauge(
116126
"tessera.appender.next_index",
117127
metric.WithDescription("The next available index to be assigned to entries"))
@@ -255,6 +265,9 @@ func NewAppender(ctx context.Context, d Driver, opts *AppendOptions) (*Appender,
255265
}
256266
// TODO(mhutchinson): move this into the decorators
257267
a.Add = func(ctx context.Context, entry *Entry) IndexFuture {
268+
if deadline, ok := ctx.Deadline(); ok {
269+
appenderDeadlineRemaining.Record(ctx, time.Until(deadline).Milliseconds())
270+
}
258271
ctx, span := tracer.Start(ctx, "tessera.Appender.Add")
259272
defer span.End()
260273

0 commit comments

Comments
 (0)