Skip to content

Commit

Permalink
Add chart for adoption rate and rollout percentage in release health
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Nov 3, 2023
1 parent 6b54c66 commit 255140e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/components/release_monitoring_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
values: { "total" => errors_count, "new" => new_errors_count },
provider: monitoring_provider,
external_url: monitoring_provider_url) %>
<% if adoption_chart_data.present? && helpers.current_user.release_monitoring? %>
<div class="col-span-2"><%= render ChartComponent.new(adoption_chart_data, icon: "sparkles.svg") %></div>
<% end %>
</div>
</article>
<% end %>
19 changes: 19 additions & 0 deletions app/components/release_monitoring_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,23 @@ def session_stability
return "-" if release_data.session_stability.blank?
"#{release_data.session_stability}%"
end

def adoption_chart_data
@chart_data ||= deployment_run
.release_health_metrics
.group_by_day(:fetched_at, last: 10)
.maximum("round(CAST(sessions_in_last_day::float * 100 / total_sessions_in_last_day::float as numeric), 2)")
.compact
.map { |k, v| [k.strftime("%d %b"), {adoption_rate: v, rollout_percentage: deployment_run.rollout_percentage_at(k)}] }
.to_h

return unless @chart_data.keys.size >= 2

{
data: @chart_data,
type: "line",
value_format: "number",
name: "release_health.adoption_rate"
}
end
end
13 changes: 13 additions & 0 deletions app/models/deployment_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DeploymentRun < ApplicationRecord
include Loggable
include Displayable
using RefinedArray
using RefinedString

belongs_to :step_run, inverse_of: :deployment_runs
belongs_to :deployment, inverse_of: :deployment_runs
Expand Down Expand Up @@ -188,6 +189,18 @@ def staged_rollout_events
end
end

def rollout_percentage_at(ts)
return 100.0 unless staged_rollout
last_event = staged_rollout
.passports
.where(reason: [:started, :increased, :fully_released])
.where("event_timestamp < ?", ts)
.order(:event_timestamp)
.last
return 100.0 if last_event.reason == "fully_released"
last_event.metadata["rollout_percentage"].safe_float
end

def submitted_at
return unless released?
return unless production_channel?
Expand Down
6 changes: 5 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ en:
not_authorized_policy: "Not Authorized %{model} on %{query} action"
not_logged_in: "You must be logged in to access this page"
charts:
release_health:
adoption_rate:
title: "Adoption Rate"
scope: "With rollout percentage"
help_text: ""
devops:
duration:
title: "Release duration"
Expand Down Expand Up @@ -279,4 +284,3 @@ en:
title: "Stability contributors"
scope: "Last 5 releases"
help_text: ""

0 comments on commit 255140e

Please sign in to comment.