Class: SolidApm::TransactionsController
Defined Under Namespace
Classes: TransactionAggregation
Instance Method Summary
collapse
Instance Method Details
#count_time_aggregations ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/solid_apm/transactions_controller.rb', line 49
def count_time_aggregations
scope = Transaction.all.order(timestamp: :desc)
.where(created_at: from_to_range)
if params[:name].present?
scope = scope.where(name: params[:name])
end
render json: aggregate(scope.select(:id, :created_at).find_each, from_to_range, intervals_count: 20).transform_values!(&:count)
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/solid_apm/transactions_controller.rb', line 7
def index
@aggregated_transactions = Transaction.where(created_at: from_to_range).group_by(&:name)
@aggregated_transactions.transform_values! do |transactions|
latency = transactions.map(&:duration).sum / transactions.size
tmp = transactions.size.to_f / ((from_to_range.end - from_to_range.begin) / 60).to_i
impact = latency * tmp
percentile_95 = transactions[transactions.size * 0.95].duration
TransactionAggregation.new(
transactions.first.name,
tmp,
latency,
percentile_95,
impact
)
end
max_impact = @aggregated_transactions.values.max_by(&:impact).impact
min_impact = @aggregated_transactions.values.min_by(&:impact).impact
@aggregated_transactions.each do |_, aggregation|
normalized_impact = ((aggregation.impact - min_impact) / (max_impact - min_impact)) * 100
normalized_impact = 0 if normalized_impact.nan?
aggregation.impact = normalized_impact.to_i || 0
end
@aggregated_transactions = @aggregated_transactions.sort_by { |_, v| -v.impact }.to_h
end
|
#show ⇒ Object
39
40
41
|
# File 'app/controllers/solid_apm/transactions_controller.rb', line 39
def show
@transaction = Transaction.find(params[:id])
end
|
#show_by_name ⇒ Object
35
36
37
|
# File 'app/controllers/solid_apm/transactions_controller.rb', line 35
def show_by_name
@transactions = Transaction.where(name: params[:name]).order(timestamp: :desc).limit(20)
end
|
#spans ⇒ Object
43
44
45
46
47
|
# File 'app/controllers/solid_apm/transactions_controller.rb', line 43
def spans
@transaction = Transaction.find(params[:id])
@spans = @transaction.spans
render json: @spans
end
|