Skip to content

Commit 5d9ff7f

Browse files
authored
chore: update symbolizer metrics (#4595)
1 parent eb30cfb commit 5d9ff7f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/symbolizer/debuginfod_client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func (c *DebuginfodHTTPClient) FetchDebuginfo(ctx context.Context, buildID strin
118118
}
119119

120120
if found, _ := c.notFoundCache.Get(sanitizedBuildID); found {
121-
c.metrics.cacheOperations.WithLabelValues("not_found", "get", statusSuccess).Inc()
122121
status = statusErrorNotFound
123122
return nil, buildIDNotFoundError{buildID: sanitizedBuildID}
124123
}
@@ -128,7 +127,10 @@ func (c *DebuginfodHTTPClient) FetchDebuginfo(ctx context.Context, buildID strin
128127
})
129128

130129
if err != nil {
130+
var bnfErr buildIDNotFoundError
131131
switch {
132+
case errors.As(err, &bnfErr):
133+
status = statusErrorNotFound
132134
case errors.Is(err, context.Canceled):
133135
status = statusErrorCanceled
134136
case errors.Is(err, context.DeadlineExceeded):
@@ -212,6 +214,7 @@ func (c *DebuginfodHTTPClient) fetchDebugInfoWithRetries(ctx context.Context, sa
212214
// Don't retry on 404 errors
213215
if statusCode, isHTTPErr := isHTTPStatusError(err); isHTTPErr && statusCode == http.StatusNotFound {
214216
c.notFoundCache.SetWithTTL(sanitizedBuildID, true, 1, c.cfg.NotFoundCacheTTL)
217+
c.metrics.cacheOperations.WithLabelValues("not_found", "set", statusSuccess).Inc()
215218
c.metrics.cacheSizeBytes.WithLabelValues("not_found").Set(float64(c.notFoundCache.Metrics.CostAdded()))
216219
return nil, buildIDNotFoundError{buildID: sanitizedBuildID}
217220
}
@@ -264,7 +267,8 @@ func isRetryableError(err error) bool {
264267
return false
265268
}
266269

267-
if _, ok := err.(buildIDNotFoundError); ok {
270+
var bnfErr buildIDNotFoundError
271+
if errors.As(err, &bnfErr) {
268272
return false
269273
}
270274

pkg/symbolizer/symbolizer.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,18 @@ func (s *Symbolizer) symbolizeWithTable(table *lidia.Table, req *request) {
302302
func (s *Symbolizer) getLidiaBytes(ctx context.Context, buildID string) ([]byte, error) {
303303
if client, ok := s.client.(*DebuginfodHTTPClient); ok {
304304
if found, _ := client.notFoundCache.Get(buildID); found {
305+
s.metrics.cacheOperations.WithLabelValues("not_found", "get", statusSuccess).Inc()
305306
return nil, buildIDNotFoundError{buildID: buildID}
306307
}
308+
s.metrics.cacheOperations.WithLabelValues("not_found", "get", "miss").Inc()
307309
}
308310

309311
lidiaBytes, err := s.fetchLidiaFromObjectStore(ctx, buildID)
310312
if err == nil {
313+
s.metrics.cacheOperations.WithLabelValues("object_storage", "get", statusSuccess).Inc()
311314
return lidiaBytes, nil
312315
}
316+
s.metrics.cacheOperations.WithLabelValues("object_storage", "get", "miss").Inc()
313317

314318
lidiaBytes, err = s.fetchLidiaFromDebuginfod(ctx, buildID)
315319
if err != nil {
@@ -318,6 +322,9 @@ func (s *Symbolizer) getLidiaBytes(ctx context.Context, buildID string) ([]byte,
318322

319323
if err := s.bucket.Upload(ctx, buildID, bytes.NewReader(lidiaBytes)); err != nil {
320324
level.Warn(s.logger).Log("msg", "Failed to store debug info in objstore", "buildID", buildID, "err", err)
325+
s.metrics.cacheOperations.WithLabelValues("object_storage", "set", "error").Inc()
326+
} else {
327+
s.metrics.cacheOperations.WithLabelValues("object_storage", "set", statusSuccess).Inc()
321328
}
322329

323330
return lidiaBytes, nil

0 commit comments

Comments
 (0)