@@ -13,6 +13,7 @@ import (
13
13
"time"
14
14
15
15
"github.com/jmoiron/sqlx"
16
+ log "github.com/sirupsen/logrus"
16
17
)
17
18
18
19
// Source represents a source
@@ -119,6 +120,7 @@ func (db *psqlxStore) ProcessSourceExecution(s Source, sourceFindings []SourceFi
119
120
if screated == nil {
120
121
return Source {}, errors .New ("unexpected nil pointer after source creation" )
121
122
}
123
+ tInit := time .Now ()
122
124
123
125
// Before updating the findings we have to lock the tx to prevent race
124
126
// conditions from other possible concurrent sources being processed.
@@ -133,6 +135,7 @@ func (db *psqlxStore) ProcessSourceExecution(s Source, sourceFindings []SourceFi
133
135
return Source {}, err
134
136
}
135
137
138
+ tRelatedFamilies := time .Now ()
136
139
for _ , sf := range sourceFindings {
137
140
err = createSourceIssue (ctx , tx , sf .IssueID , screated .ID )
138
141
if err != nil {
@@ -162,6 +165,7 @@ func (db *psqlxStore) ProcessSourceExecution(s Source, sourceFindings []SourceFi
162
165
}
163
166
}
164
167
168
+ tFindings := time .Now ()
165
169
findingStates , err := findingsStates (ctx , tx , db .logger , screated .SourceFamily )
166
170
if err != nil {
167
171
tx .Rollback ()
@@ -174,6 +178,18 @@ func (db *psqlxStore) ProcessSourceExecution(s Source, sourceFindings []SourceFi
174
178
return Source {}, err
175
179
}
176
180
181
+ db .logger .WithFields (log.Fields {
182
+ "msRelatedFamilies" : tRelatedFamilies .Sub (tInit ).Milliseconds (),
183
+ "msFindings" : tFindings .Sub (tRelatedFamilies ).Milliseconds (),
184
+ "msFindingStates" : time .Since (tFindings ).Milliseconds (),
185
+ "msTotal" : time .Since (tInit ).Milliseconds (),
186
+ "numFindingStates" : len (findingStates ),
187
+ "numSourceFindings" : len (sourceFindings ),
188
+ "target" : s .Target ,
189
+ "check" : s .Instance ,
190
+ "component" : s .Component ,
191
+ }).Info ("ProcessSourceExecution" )
192
+
177
193
return * screated , tx .Commit ()
178
194
}
179
195
0 commit comments