Skip to content

Commit

Permalink
Only collect rollup associations
Browse files Browse the repository at this point in the history
VimPerformanceState are used to represent an object in the past.
These records are used for metrics rollups, metric calculations, and chargeback calculations
Do note, that chargeback calculations do contain some form of a rollup.

We only rollup metrics by the PERF_ROLLUP_CHILDREN association.
Collecting all these other grow our VimPerformanceState table and take up processing time,
for collecting vps and downloading vps.
  • Loading branch information
kbrock committed Jul 15, 2023
1 parent 5805be9 commit fa48674
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/metric/ci_mixin/state_finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def vim_performance_state_association(ts, assoc)
@last_vps_ts = ts
# we are using a different timestamp
# clear out relevant associations
(VimPerformanceState::ASSOCIATIONS & self.class.reflections.keys.map(&:to_sym)).each do |vps_assoc|
((VimPerformanceState::ASSOCIATIONS + self.class::PERF_ROLLUP_CHILDREN)& self.class.reflections.keys.map(&:to_sym)).each do |vps_assoc|
association(vps_assoc).reset
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/vim_performance_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class VimPerformanceState < ApplicationRecord

belongs_to :resource, :polymorphic => true

ASSOCIATIONS = [:vms, :hosts, :ems_clusters, :ext_management_systems, :storages, :container_nodes, :container_groups,
:all_container_groups, :containers]
# we want these even if we don't roll them up
ASSOCIATIONS = Metric::Rollup::ASSOC_KEYS

# Define accessors for state_data information
[
Expand Down Expand Up @@ -187,7 +187,7 @@ def capture_total(field)

def capture_assoc_ids
result = {}
ASSOCIATIONS.each do |assoc|
(ASSOCIATIONS + resource.class::PERF_ROLLUP_CHILDREN).uniq.each do |assoc|
method = if assoc == :vms
if resource.kind_of?(EmsCluster)
:all_vms_and_templates
Expand Down

0 comments on commit fa48674

Please sign in to comment.