Skip to content

Commit

Permalink
Merge pull request #10246 from hennevogel/feature/build-hm
Browse files Browse the repository at this point in the history
Publish build events to the metrics bus
  • Loading branch information
hennevogel committed Oct 2, 2020
2 parents 39be5f1 + d20a027 commit a65d1fd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/api/app/models/event/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,41 @@ def custom_headers
h
end

def metric_measurement
'build'
end

def metric_tags
{
namespace: payload['project'].split(':').first,
worker: payload['workerid'],
arch: payload['arch'],
reason: reason,
state: state
}
end

def metric_fields
{
duration: duration_in_seconds,
latency: latency_in_seconds
}
end

private

def duration_in_seconds
payload['endtime'].to_i - payload['starttime'].to_i
end

def latency_in_seconds
payload['starttime'].to_i - payload['readytime'].to_i
end

def reason
payload['reason'].parameterize.underscore
end

def my_message_id
# we put the verifymd5 sum in the message id, so new checkins get new thread, but it doesn't have to be very correct
md5 = payload.fetch('verifymd5', 'NOVERIFY')[0..6]
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/event/build_fail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def custom_headers
h
end

def state
'fail'
end

private

def faillog
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/event/build_success.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module Event
class BuildSuccess < Build
self.message_bus_routing_key = 'package.build_success'
self.description = 'Package has succeeded building'

def state
'success'
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/event/build_unchanged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module Event
class BuildUnchanged < Build
self.message_bus_routing_key = 'package.build_unchanged'
self.description = 'Package has succeeded building with unchanged result'

def state
'unchanged'
end
end
end

Expand Down

0 comments on commit a65d1fd

Please sign in to comment.