@@ -81,12 +81,9 @@ type Store struct {
8181 metadata MetadataManager
8282 debuginfodClient DebugInfodClient
8383
84- validationAttemptsTotal prometheus.Counter
85- validationErrorsTotal prometheus.CounterVec
86- metadataUpdateDuration prometheus.Histogram
87- uploadDebugInfoAttemptsTotal prometheus.Counter
88- uploadDebugInfoErrorsTotal prometheus.CounterVec
89- uploadDebugInfoDuration prometheus.Histogram
84+ debugInfoUploadAttemptsTotal prometheus.Counter
85+ debugInfoUploadErrorsTotal prometheus.CounterVec
86+ debugInfoUploadDuration prometheus.Histogram
9087 existsCheckDuration prometheus.Histogram
9188}
9289
@@ -100,20 +97,20 @@ func NewStore(
10097 bucket objstore.Bucket ,
10198 debuginfodClient DebugInfodClient ,
10299) (* Store , error ) {
103- uploadDebugInfoAttemptsTotal := prometheus .NewCounter (
100+ debugInfoUploadAttemptsTotal := prometheus .NewCounter (
104101 prometheus.CounterOpts {
105102 Name : "debuginfo_upload_attempts_total" ,
106103 Help : "Total attempts to upload debuginfo." ,
107104 },
108105 )
109- uploadDebugInfoErrorsTotal := prometheus .NewCounterVec (
106+ debugInfoUploadErrorsTotal := prometheus .NewCounterVec (
110107 prometheus.CounterOpts {
111108 Name : "debuginfo_upload_errors_total" ,
112109 Help : "Total number of errors in uploading debuginfo." ,
113110 },
114111 []string {"reason" },
115112 )
116- uploadDebugInfoDuration := prometheus .NewHistogram (
113+ debugInfoUploadDuration := prometheus .NewHistogram (
117114 prometheus.HistogramOpts {
118115 Name : "debuginfo_upload_duration_seconds" ,
119116 Help : "How long it took in seconds to upload debuginfo." ,
@@ -129,39 +126,16 @@ func NewStore(
129126 },
130127 )
131128
132- metadataUpdateDuration := prometheus .NewHistogram (
133- prometheus.HistogramOpts {
134- Name : "debuginfo_metadata_update_duration_seconds" ,
135- Help : "How long it took in seconds to finish updating metadata." ,
136- Buckets : []float64 {0.001 , 0.01 , 0.1 , 0.3 , 0.6 , 1 , 3 , 6 , 9 , 20 , 30 , 60 , 90 , 120 },
137- },
138- )
139- validationAttemptsTotal := prometheus .NewCounter (
140- prometheus.CounterOpts {
141- Name : "debuginfo_validate_object_file_attempts_total" ,
142- Help : "Total number of validation of object file." ,
143- },
144- )
145- validationErrorsTotal := prometheus .NewCounterVec (
146- prometheus.CounterOpts {
147- Name : "debuginfo_validate_object_file_errors_total" ,
148- Help : "Total number of errors in validationg object file." ,
149- },
150- []string {"reason" },
151- )
152129 return & Store {
153130 tracer : tracer ,
154131 logger : log .With (logger , "component" , "debuginfo" ),
155132 bucket : bucket ,
156133 cacheDir : cacheDir ,
157134 metadata : metadata ,
158135 debuginfodClient : debuginfodClient ,
159- metadataUpdateDuration : metadataUpdateDuration ,
160- validationAttemptsTotal : validationAttemptsTotal ,
161- validationErrorsTotal : * validationErrorsTotal ,
162- uploadDebugInfoAttemptsTotal : uploadDebugInfoAttemptsTotal ,
163- uploadDebugInfoErrorsTotal : * uploadDebugInfoErrorsTotal ,
164- uploadDebugInfoDuration : uploadDebugInfoDuration ,
136+ debugInfoUploadAttemptsTotal : debugInfoUploadAttemptsTotal ,
137+ debugInfoUploadErrorsTotal : * debugInfoUploadErrorsTotal ,
138+ debugInfoUploadDuration : debugInfoUploadDuration ,
165139 existsCheckDuration : existsCheckDuration ,
166140 }, nil
167141}
@@ -210,12 +184,12 @@ func (s *Store) Exists(ctx context.Context, req *debuginfopb.ExistsRequest) (*de
210184
211185func (s * Store ) Upload (stream debuginfopb.DebugInfoService_UploadServer ) error {
212186 defer func (begin time.Time ) {
213- s .uploadDebugInfoDuration .Observe (time .Since (begin ).Seconds ())
187+ s .debugInfoUploadDuration .Observe (time .Since (begin ).Seconds ())
214188 }(time .Now ())
215- s .uploadDebugInfoAttemptsTotal .Inc ()
189+ s .debugInfoUploadAttemptsTotal .Inc ()
216190 req , err := stream .Recv ()
217191 if err != nil {
218- s .uploadDebugInfoErrorsTotal .WithLabelValues ("stream_receive" ).Inc ()
192+ s .debugInfoUploadErrorsTotal .WithLabelValues ("stream_receive" ).Inc ()
219193 msg := "failed to receive upload info"
220194 level .Error (s .logger ).Log ("msg" , msg , "err" , err )
221195 return status .Errorf (codes .Unknown , msg )
@@ -233,7 +207,7 @@ func (s *Store) Upload(stream debuginfopb.DebugInfoService_UploadServer) error {
233207 span .SetAttributes (attribute .String ("hash" , hash ))
234208
235209 if err := s .upload (ctx , buildID , hash , r ); err != nil {
236- s .uploadDebugInfoErrorsTotal .WithLabelValues ("store_upload" ).Inc ()
210+ s .debugInfoUploadErrorsTotal .WithLabelValues ("store_upload" ).Inc ()
237211 return err
238212 }
239213
@@ -298,14 +272,13 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
298272 if err != nil {
299273 return status .Error (codes .Internal , err .Error ())
300274 }
301- s .validationAttemptsTotal .Inc ()
302275 if err := elfutils .ValidateFile (objFile ); err != nil {
276+ s .debugInfoUploadErrorsTotal .WithLabelValues ("validation" ).Inc ()
303277 // Failed to validate. Mark the file as corrupted, and let the client try to upload it again.
304278 if err := s .metadata .MarkAsCorrupted (ctx , buildID ); err != nil {
305279 level .Warn (s .logger ).Log ("msg" , "failed to update metadata as corrupted" , "err" , err )
306280 }
307281 level .Error (s .logger ).Log ("msg" , "failed to validate object file" , "buildid" , buildID )
308- s .validationErrorsTotal .WithLabelValues ("validate_object_file" ).Inc ()
309282 // Client will retry.
310283 return status .Error (codes .Internal , err .Error ())
311284 }
@@ -318,7 +291,6 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
318291 hasDWARF , err := elfutils .HasDWARF (f )
319292 if err != nil {
320293 level .Debug (s .logger ).Log ("msg" , "failed to check for DWARF" , "err" , err )
321- s .validationErrorsTotal .WithLabelValues ("has_dwarf_object_file" ).Inc ()
322294 }
323295 f .Close ()
324296 if hasDWARF {
@@ -329,9 +301,6 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
329301
330302 // At this point we know that we received a better version of the debug information file,
331303 // so let the client upload it.
332- defer func (begin time.Time ) {
333- s .metadataUpdateDuration .Observe (time .Since (begin ).Seconds ())
334- }(time .Now ())
335304 if err := s .metadata .MarkAsUploading (ctx , buildID ); err != nil {
336305 err = fmt .Errorf ("failed to update metadata before uploading: %w" , err )
337306 return status .Error (codes .Internal , err .Error ())
@@ -357,7 +326,6 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
357326 }
358327
359328 if err := elfutils .ValidateHeader (b ); err != nil {
360- s .validationErrorsTotal .WithLabelValues ("validate_header_object_file" ).Inc ()
361329 // Failed to validate. Mark the incoming stream as corrupted, and let the client try to upload it again.
362330 if err := s .metadata .MarkAsCorrupted (ctx , buildID ); err != nil {
363331 err = fmt .Errorf ("failed to update metadata after uploaded, as corrupted: %w" , err )
0 commit comments