Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha committed Sep 13, 2023
1 parent 17a5b95 commit 16c1f11
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ func newTileCachingHandler(
latencyMetric := prometheus.NewHistogram(
prometheus.HistogramOpts{
Name: "ctile_response_latency_seconds",
Help: "latency of responses",
Help: "overall latency of responses, including all backend requests",
Buckets: prometheus.DefBuckets,
})
promRegisterer.MustRegister(latencyMetric)

backendLatencyMetric := prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "ctile_backend_latency_seconds",
Help: "latency of responses",
Help: "latency of each backend request",
Buckets: prometheus.DefBuckets,
},
[]string{"backend"})
Expand Down Expand Up @@ -487,9 +487,9 @@ func (tch *tileCachingHandler) getAndCacheTile(ctx context.Context, tile tile) (
// getAndCacheTileUncollapsed is the core of getAndCacheTile (and is used by it)
// without the request collapsing. Use getAndCacheTile instead of this method.
func (tch *tileCachingHandler) getAndCacheTileUncollapsed(ctx context.Context, tile tile) (*entries, tileSource, error) {
begin := time.Now()
beginS3Get := time.Now()
contents, err := tch.getFromS3(ctx, tile)
tch.backendLatencyMetric.WithLabelValues("s3_get").Observe(time.Since(begin).Seconds())
tch.backendLatencyMetric.WithLabelValues("s3_get").Observe(time.Since(beginS3Get).Seconds())

if err == nil {
return contents, sourceS3, nil
Expand All @@ -500,9 +500,9 @@ func (tch *tileCachingHandler) getAndCacheTileUncollapsed(ctx context.Context, t
return nil, sourceS3, fmt.Errorf("error reading tile from s3: %w", err)
}

begin = time.Now()
beginCTLogGet := time.Now()
contents, err = getTileFromBackend(ctx, tile)
tch.backendLatencyMetric.WithLabelValues("ct_log_get").Observe(time.Since(begin).Seconds())
tch.backendLatencyMetric.WithLabelValues("ct_log_get").Observe(time.Since(beginCTLogGet).Seconds())

if err != nil {
var statusCodeErr statusCodeError
Expand All @@ -524,9 +524,9 @@ func (tch *tileCachingHandler) getAndCacheTileUncollapsed(ctx context.Context, t
return contents, sourceCTLog, nil
}

begin = time.Now()
beginS3Put := time.Now()
err = tch.writeToS3(ctx, tile, contents)
tch.backendLatencyMetric.WithLabelValues("s3_put").Observe(time.Since(begin).Seconds())
tch.backendLatencyMetric.WithLabelValues("s3_put").Observe(time.Since(beginS3Put).Seconds())

if err != nil {
tch.requestsMetric.WithLabelValues("error", "s3_put").Inc()
Expand Down

0 comments on commit 16c1f11

Please sign in to comment.