@@ -11,6 +11,7 @@ import (
11
11
12
12
"github.com/ovh/cds/engine/api/application"
13
13
"github.com/ovh/cds/engine/api/cache"
14
+ "github.com/ovh/cds/engine/api/observability"
14
15
"github.com/ovh/cds/engine/api/repositoriesmanager"
15
16
"github.com/ovh/cds/engine/api/services"
16
17
"github.com/ovh/cds/sdk"
@@ -19,6 +20,9 @@ import (
19
20
20
21
// HookRegistration ensures hooks registration on Hook µSer
8000
vice
21
22
func HookRegistration (ctx context.Context , db gorp.SqlExecutor , store cache.Store , oldW * sdk.Workflow , wf sdk.Workflow , p * sdk.Project ) error {
23
+ ctx , end := observability .Span (ctx , "workflow.HookRegistration" )
24
+ defer end ()
25
+
22
26
var hookToUpdate map [string ]sdk.WorkflowNodeHook
23
27
var hookToDelete map [string ]sdk.WorkflowNodeHook
24
28
if oldW != nil {
@@ -27,6 +31,9 @@ func HookRegistration(ctx context.Context, db gorp.SqlExecutor, store cache.Stor
27
31
hookToUpdate = wf .GetHooks ()
28
32
}
29
33
34
+ observability .Current (ctx , observability .Tag ("hook_update_count" , len (hookToUpdate )))
35
+ observability .Current (ctx , observability .Tag ("hook_delete_count" , len (hookToDelete )))
36
+
30
37
if len (hookToUpdate ) > 0 {
31
38
//Push the hook to hooks µService
32
39
//Load service "hooks"
@@ -151,8 +158,12 @@ func HookRegistration(ctx context.Context, db gorp.SqlExecutor, store cache.Stor
151
158
152
159
// DeleteHookConfiguration delete hooks configuration (and their vcs configuration)
153
160
func DeleteHookConfiguration (ctx context.Context , db gorp.SqlExecutor , store cache.Store , p * sdk.Project , hookToDelete map [string ]sdk.WorkflowNodeHook ) error {
161
+ ctx , end := observability .Span (ctx , "workflow.DeleteHookConfiguration" )
162
+ defer end ()
154
163
// Delete from vcs configuration if needed
164
+ count := 0
155
165
for _ , h := range hookToDelete {
166
+ count ++
156
167
if h .WorkflowHookModel .Name == sdk .RepositoryWebHookModelName {
157
168
// Call VCS to know if repository allows webhook and get the configuration fields
158
169
projectVCSServer := repositoriesmanager .GetProjectVCSServer (p , h .Config ["vcsServer" ].Value )
@@ -170,6 +181,8 @@ func DeleteHookConfiguration(ctx context.Context, db gorp.SqlExecutor, store cac
170
181
if err := client .DeleteHook (ctx , h .Config ["repoFullName" ].Value , vcsHook ); err != nil {
171
182
log .Error ("deleteHookConfiguration> Cannot delete hook on repository %s" , err )
172
183
}
184
+ observability .Current (ctx , observability .Tag (fmt .Sprintf ("UUID_%d" , count ), h .UUID ))
185
+ observability .Current (ctx , observability .Tag (fmt .Sprintf ("VCS_ID_%d" , count ), vcsHook .ID ))
173
186
h .Config ["webHookID" ] = sdk.WorkflowNodeHookConfigValue {
174
187
Value : vcsHook .ID ,
175
188
Configurable : false ,
@@ -194,6 +207,9 @@ func DeleteHookConfiguration(ctx context.Context, db gorp.SqlExecutor, store cac
194
207
}
195
208
196
209
func createVCSConfiguration (ctx context.Context , db gorp.SqlExecutor , store cache.Store , p * sdk.Project , h * sdk.WorkflowNodeHook ) error {
210
+ ctx , end := observability .Span (ctx , "workflow.createVCSConfiguration" , observability .Tag ("UUID" , h .UUID ))
211
+ defer end ()
212
+
197
213
// Call VCS to know if repository allows webhook and get the configuration fields
198
214
projectVCSServer := repositoriesmanager .GetProjectVCSServer (p , h .Config ["vcsServer" ].Value )
199
215
if projectVCSServer == nil {
@@ -219,6 +235,7 @@ func createVCSConfiguration(ctx context.Context, db gorp.SqlExecutor, store cach
219
235
if err := client .CreateHook (ctx , h .Config ["repoFullName" ].Value , & vcsHook ); err != nil {
220
236
return sdk .WrapError (err , "Cannot create hook on repository: %+v" , vcsHook )
221
237
}
238
+ observability .Current (ctx , observability .Tag ("VCS_ID" , vcsHook .ID ))
222
239
h .Config ["webHookID" ] = sdk.WorkflowNodeHookConfigValue {
223
240
Value : vcsHook .ID ,
224
241
Configurable : false ,
0 commit comments