@@ -40,7 +40,7 @@ defmodule HooksProcessor.Hooks.Processing.BitbucketWorker do
40
40
requester_id <- get_requester_id ( webhook , actor_id , "bitbucket" ) ,
41
41
{ :ok , _webhook } <-
42
42
process_webhook ( hook_type , webhook , project . repository , requester_id ) do
43
- "Processing finished successfully." |> graceful_exit ( state )
43
+ :ok |> graceful_exit ( state )
44
44
else
45
45
error -> graceful_exit ( error , state )
46
46
end
@@ -94,6 +94,9 @@ defmodule HooksProcessor.Hooks.Processing.BitbucketWorker do
94
94
end
95
95
96
96
defp process_webhook ( hook_type , _webhook , _project , _requester_id ) do
97
+ # Increment unsupported hook type metric
98
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "unsupported_hook" ] } )
99
+
97
100
"Unsuported type of the hook: '#{ hook_type } '"
98
101
end
99
102
@@ -109,9 +112,15 @@ defmodule HooksProcessor.Hooks.Processing.BitbucketWorker do
109
112
defp should_build? ( repository , hook_data , hook_type ) do
110
113
cond do
111
114
hook_type not in repository . run_on ->
115
+ # Increment skip configuration metric
116
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "skip" , "configuration" ] } )
117
+
112
118
{ :build , { false , hook_state ( hook_type , :skip ) } , hook_data }
113
119
114
120
not whitelisted? ( repository . whitelist , hook_data , hook_type ) ->
121
+ # Increment skip configuration metric
122
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "skip" , "whitelist" ] } )
123
+
115
124
{ :build , { false , hook_state ( hook_type , :whitelist ) } , hook_data }
116
125
117
126
true ->
@@ -124,14 +133,28 @@ defmodule HooksProcessor.Hooks.Processing.BitbucketWorker do
124
133
defp hook_state ( :TAGS , :skip ) , do: "skip_tag"
125
134
defp hook_state ( :TAGS , :whitelist ) , do: "whitelist_tag"
126
135
127
- defp graceful_exit ( message , state ) do
128
- message
129
- |> LT . info ( "Hook #{ state . id } - bitbucket worker process exits: " )
136
+ defp graceful_exit ( result , state ) do
137
+ case result do
138
+ :ok ->
139
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "success" ] } )
140
+
141
+ "Processing finished successfully."
142
+ |> LT . debug ( "Hook #{ state . id } - bitbucket worker process exits: " )
143
+
144
+ error ->
145
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "error" ] } )
146
+
147
+ error
148
+ |> LT . error ( "Hook #{ state . id } - bitbucket worker process exits: " )
149
+ end
130
150
131
151
{ :stop , :normal , state }
132
152
end
133
153
134
154
defp restart ( error , state ) do
155
+ # Increment failure metric
156
+ Watchman . increment ( { "hooks.processing.bitbucket" , [ "restart" ] } )
157
+
135
158
error
136
159
|> LT . warn ( "Hook #{ state . id } - bitbucket worker process failiure: " )
137
160
0 commit comments