@@ -13,7 +13,6 @@ import (
13
13
"regexp"
14
14
"time"
15
15
16
- "github.com/dgraph-io/ristretto"
17
16
"github.com/go-kit/log"
18
17
"github.com/go-kit/log/level"
19
18
"github.com/grafana/dskit/backoff"
@@ -58,9 +57,6 @@ type DebuginfodHTTPClient struct {
58
57
metrics * Metrics
59
58
logger log.Logger
60
59
61
- // In-memory cache of build IDs to debug info data
62
- cache * ristretto.Cache
63
-
64
60
// Used to deduplicate concurrent requests for the same build ID
65
61
group singleflight.Group
66
62
}
@@ -77,13 +73,6 @@ func NewDebuginfodClient(logger log.Logger, baseURL string, metrics *Metrics) (*
77
73
MaxBackoff : 10 * time .Second ,
78
74
MaxRetries : 3 ,
79
75
},
80
- CacheConfig : struct {
81
- MaxSizeBytes int64
82
- NumCounters int64
83
- }{
84
- MaxSizeBytes : 2 << 30 , // 2GB default
85
- NumCounters : 1e7 , // 10M default
86
- },
87
76
}, metrics )
88
77
}
89
78
@@ -111,25 +100,6 @@ func NewDebuginfodClientWithConfig(logger log.Logger, cfg DebuginfodClientConfig
111
100
}
112
101
}
113
102
114
- // Use default cache config if not specified
115
- if cfg .CacheConfig .MaxSizeBytes == 0 {
116
- cfg .CacheConfig .MaxSizeBytes = 2 << 30 // 2GB default
117
- }
118
- if cfg .CacheConfig .NumCounters == 0 {
119
- cfg .CacheConfig .NumCounters = 1e7 // 10M default
120
- }
121
-
122
- // Create cache
123
- cache , err := ristretto .NewCache (& ristretto.Config {
124
- NumCounters : cfg .CacheConfig .NumCounters ,
125
- MaxCost : cfg .CacheConfig .MaxSizeBytes ,
126
- BufferItems : 64 , // number of keys per Get buffer
127
- })
128
-
129
- if err != nil {
130
- return nil , fmt .Errorf ("failed to create debuginfod cache: %w" , err )
131
- }
132
-
133
103
return & DebuginfodHTTPClient {
134
104
cfg : DebuginfodClientConfig {
135
105
BaseURL : cfg .BaseURL ,
@@ -140,7 +110,6 @@ func NewDebuginfodClientWithConfig(logger log.Logger, cfg DebuginfodClientConfig
140
110
CacheConfig : cfg .CacheConfig ,
141
111
},
142
112
metrics : metrics ,
143
- cache : cache ,
144
113
logger : logger ,
145
114
}, nil
146
115
}
@@ -155,22 +124,22 @@ func (c *DebuginfodHTTPClient) FetchDebuginfo(ctx context.Context, buildID strin
155
124
c .metrics .debuginfodRequestDuration .WithLabelValues (status ).Observe (time .Since (start ).Seconds ())
156
125
}()
157
126
127
+ level .Debug (c .logger ).Log (
128
+ "msg" , "symbolizer: starting debuginfod fetch" ,
129
+ "build_id" , buildID ,
130
+ )
131
+
158
132
sanitizedBuildID , err := sanitizeBuildID (buildID )
159
133
if err != nil {
160
134
status = StatusErrorInvalidID
161
135
return nil , err
162
136
}
163
137
164
- // Check in-memory cache first
165
- if c .cache != nil {
166
- if data , found := c .cache .Get (sanitizedBuildID ); found {
167
- status = StatusCacheHit
168
- return io .NopCloser (bytes .NewReader (data .([]byte ))), nil
169
- }
170
- }
171
-
172
138
// Check if there's already a request in flight for this build ID
173
- // This prevents duplicate requests for the same build ID
139
+ level .Debug (c .logger ).Log (
140
+ "msg" , "symbolizer: making debuginfod request" ,
141
+ "build_id" , sanitizedBuildID ,
142
+ )
174
143
v , err , _ := c .group .Do (sanitizedBuildID , func () (interface {}, error ) {
175
144
return c .fetchDebugInfoWithRetries (ctx , sanitizedBuildID )
176
145
})
@@ -193,6 +162,11 @@ func (c *DebuginfodHTTPClient) FetchDebuginfo(ctx context.Context, buildID strin
193
162
194
163
data := v .([]byte )
195
164
c .metrics .debuginfodFileSize .Observe (float64 (len (data )))
165
+ level .Debug (c .logger ).Log (
166
+ "msg" , "symbolizer: debuginfod fetch successful" ,
167
+ "build_id" , sanitizedBuildID ,
168
+ "size" , len (data ),
169
+ )
196
170
return io .NopCloser (bytes .NewReader (data )), nil
197
171
}
198
172
@@ -255,7 +229,7 @@ func (c *DebuginfodHTTPClient) fetchDebugInfoWithRetries(ctx context.Context, sa
255
229
statusCode , isHTTPErr := isHTTPStatusError (err )
256
230
if isHTTPErr && statusCode == http .StatusNotFound {
257
231
lastErr = buildIDNotFoundError {buildID : sanitizedBuildID }
258
- return true // Stop retrying on 404
232
+ return true
259
233
}
260
234
261
235
// Store the error for later reporting
@@ -287,19 +261,6 @@ func (c *DebuginfodHTTPClient) fetchDebugInfoWithRetries(ctx context.Context, sa
287
261
return nil , fmt .Errorf ("failed to fetch debuginfo after %d attempts: %w" , backOff .NumRetries (), lastErr )
288
262
}
289
263
290
- // Store successful result in cache
291
- if c .cache != nil {
292
- // The cost is the size of the data in bytes
293
- success := c .cache .Set (sanitizedBuildID , data , int64 (len (data )))
294
- if ! success && c .logger != nil {
295
- level .Warn (c .logger ).Log (
296
- "msg" , "Failed to store debuginfo in cache" ,
297
- "sanitizedBuildID" , sanitizedBuildID ,
298
- "size" , len (data ),
299
- )
300
- }
301
- }
302
-
303
264
return data , nil
304
265
}
305
266
@@ -376,6 +337,10 @@ func isRetryableError(err error) bool {
376
337
// It validates that the build ID contains only alphanumeric characters, underscores, and hyphens.
377
338
// This prevents potential security issues like path traversal attacks.
378
339
func sanitizeBuildID (buildID string ) (string , error ) {
340
+ if buildID == "" {
341
+ return "" , invalidBuildIDError {buildID : buildID }
342
+ }
343
+
379
344
// Only allow alphanumeric characters, underscores, and hyphens
380
345
validBuildID := regexp .MustCompile (`^[a-zA-Z0-9_-]+$` )
381
346
if ! validBuildID .MatchString (buildID ) {
0 commit comments