@@ -18,6 +18,7 @@ import (
1818 "github.com/l3montree-dev/devguard/monitoring"
1919 "github.com/l3montree-dev/devguard/shared"
2020 "github.com/l3montree-dev/devguard/utils"
21+ "go.opentelemetry.io/otel/attribute"
2122 "go.opentelemetry.io/otel/codes"
2223 "golang.org/x/sync/errgroup"
2324 "oras.land/oras-go/v2"
@@ -323,6 +324,11 @@ func (s *VulnDBService) ImportRC(ctx context.Context, opts shared.ImportOptions)
323324 if opts .Bulk {
324325 processingMode = "bulk"
325326 }
327+ span .SetAttributes (
328+ attribute .String ("vulndb.mode" , importMode ),
329+ attribute .String ("vulndb.processing" , processingMode ),
330+ attribute .Bool ("vulndb.retried" , false ),
331+ )
326332 slog .Info ("start vulndb import" , "mode" , importMode , "processing" , processingMode , "limitedToTables" , opts .LimitedToTables )
327333 start := time .Now ()
328334
@@ -370,6 +376,10 @@ func (s *VulnDBService) ImportRC(ctx context.Context, opts shared.ImportOptions)
370376 slog .Error ("integrity validation failed, attempting fallback retry" , "failingTables" , failingTables , "error" , err )
371377 monitoring .Alert ("vulndb integrity check failed, retrying with limited table set" , err )
372378
379+ span .SetAttributes (
380+ attribute .Bool ("vulndb.retried" , true ),
381+ attribute .StringSlice ("vulndb.retry.failing_tables" , failingTables ),
382+ )
373383 slog .Info ("retrying with full import for limited tables" , "tables" , failingTables )
374384
375385 // since we did not commit anything until now, the staging tables still contain some data
@@ -385,9 +395,11 @@ func (s *VulnDBService) ImportRC(ctx context.Context, opts shared.ImportOptions)
385395 return fmt .Errorf ("could not rollback transaction after failed full import retry: %w (rollback error: %v)" , err , rbErr )
386396 }
387397
398+ span .SetAttributes (attribute .String ("vulndb.retry.outcome" , "failure" ))
388399 monitoring .Alert ("vulndb integrity check failed after full import fallback" , err )
389400 return fmt .Errorf ("integrity validation failed after full import fallback: %w" , err )
390401 }
402+ span .SetAttributes (attribute .String ("vulndb.retry.outcome" , "success" ))
391403 }
392404
393405 slog .Info ("successfully passed integrity validation" , "importTimestamp" , integrity .ImportTimestamp )
0 commit comments