solid_apm 0.3.0 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6233330338e9044097e1315840f1bbc7f2cdeb1677df3dac3261c2a50666046
4
- data.tar.gz: 37f306cf60295e74485092216c4bdbe2ba2c824ce08d279424e15c631543b33f
3
+ metadata.gz: efcb9cac89d539656968bd244d4aa9b369c5bac01241bc4b87f4a4d3d374e231
4
+ data.tar.gz: 322c070fe1eeafa50f4628fa54a59a26361b779427adbdf2aa861305891d27d9
5
5
  SHA512:
6
- metadata.gz: 18d46f142b8bc401acc9dcd3417c9782d04a6e2beabda8d3c7dbafd62429f8bcf13e69ecf2e7fe51049f17da8b35411c3b1239c3f9476950590917990d0c7aba
7
- data.tar.gz: a0140e3fdb51254f8c615ed7cd4002f851d0c1ef11b71d408c4966581b1638f475ada593977a53761631493201e53641df382b9c8d9c10598935fe7ae8b50da3
6
+ metadata.gz: 4be9f2e4f94ddd42dac90ce6345a0601cd13060154a98f2a915152fafc09df8886281efa7cd5b024769331762c7ec2b1cb0f3d64f3ccb0d700206fc85a1ef787
7
+ data.tar.gz: 79bcd0928c31b6199fab8ef1d455bcd635aa7ee6aec5465138a841876d268e943b32e077ff5958cd395591fa3e87586343671163fd8602904ed4a0c029686a15
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  # SolidApm
4
4
  Rails engine to manage APM data without using a third party service.
5
5
 
6
- <img src="./docs/img.png" width="400px">
7
- <img src="./docs/img_1.png" width="400px">
6
+ <img src="./docs/img.png" width="600px">
7
+ <img src="./docs/img_1.png" width="600px">
8
8
 
9
9
  ## Installation
10
10
 
@@ -69,9 +69,8 @@ Contribution directions go here.
69
69
  ## Release
70
70
 
71
71
  ```shell
72
- gem bump -v minor
73
- bundle install && git add . && git commit --amend --no-edit
74
- gem tag -p
72
+ bin/bump major|minor|patch
73
+ # GitHub Actions will take care of the rest
75
74
  ```
76
75
 
77
76
  ## License
@@ -28,6 +28,9 @@ window.Stimulus.register('transaction-chart',
28
28
  xaxis: {
29
29
  type: 'datetime'
30
30
  },
31
+ dataLabels: {
32
+ enabled: false
33
+ },
31
34
  tooltip: {
32
35
  x: {
33
36
  formatter: function (value) {
@@ -37,9 +40,16 @@ window.Stimulus.register('transaction-chart',
37
40
  }
38
41
  }
39
42
 
40
- let path = 'transactions/count_by_minutes'
43
+ let path = window.location.pathname.includes('transactions') ? 'count_by_minutes' : 'transactions/count_by_minutes';
44
+ path = path + "?";
41
45
  if (this.nameValue) {
42
- path = path + "?name=" + encodeURIComponent(this.nameValue);
46
+ path = path + "name=" + encodeURIComponent(this.nameValue);
47
+ }
48
+
49
+ const fromValue = document.querySelector('input[name="from_value"]').value
50
+ const fromUnit = document.querySelector('select[name="from_unit"]').value;
51
+ if (fromValue && fromUnit) {
52
+ path = path + "&from_value=" + fromValue + "&from_unit=" + fromUnit;
43
53
  }
44
54
 
45
55
  fetch(path)
@@ -2,18 +2,20 @@
2
2
 
3
3
  module SolidApm
4
4
  class TransactionsController < ApplicationController
5
- TransactionAggregation = Struct.new(:name, :tmp, :latency, :impact)
5
+ TransactionAggregation = Struct.new(:name, :tmp, :latency, :percentile_95, :impact)
6
6
 
7
7
  def index
8
- @aggregated_transactions = Transaction.where(created_at: 1.hour.ago..).group_by(&:name)
8
+ @aggregated_transactions = Transaction.where(created_at: from_to_range).group_by(&:name)
9
9
  @aggregated_transactions.transform_values! do |transactions|
10
10
  latency = transactions.map(&:duration).sum / transactions.size
11
- tmp = transactions.size.to_f / 60
11
+ tmp = transactions.size.to_f / ((from_to_range.end - from_to_range.begin) / 60).to_i
12
12
  impact = latency * tmp
13
+ percentile_95 = transactions[transactions.size * 0.95].duration
13
14
  TransactionAggregation.new(
14
15
  transactions.first.name,
15
16
  tmp,
16
17
  latency,
18
+ percentile_95,
17
19
  impact
18
20
  )
19
21
  end
@@ -24,7 +26,8 @@ module SolidApm
24
26
  # Normalize impact 0-100
25
27
  @aggregated_transactions.each do |_, aggregation|
26
28
  normalized_impact = ((aggregation.impact - min_impact) / (max_impact - min_impact)) * 100
27
- aggregation.impact = normalized_impact.to_i
29
+ normalized_impact = 0 if normalized_impact.nan?
30
+ aggregation.impact = normalized_impact.to_i || 0
28
31
  end
29
32
  @aggregated_transactions = @aggregated_transactions.sort_by { |_, v| -v.impact }.to_h
30
33
  end
@@ -45,7 +48,7 @@ module SolidApm
45
48
 
46
49
  def count_by_minutes
47
50
  scope = Transaction.all.order(timestamp: :desc)
48
- .where(created_at: 1.hour.ago..)
51
+ .where(created_at: from_to_range)
49
52
 
50
53
  if params[:name].present?
51
54
  scope = scope.where(name: params[:name])
@@ -54,5 +57,15 @@ module SolidApm
54
57
  render json: scope.group_by { |t| t.created_at.beginning_of_minute }
55
58
  .transform_values!(&:count)
56
59
  end
60
+
61
+ private
62
+
63
+ def from_to_range
64
+ params[:from_value] ||= 60
65
+ params[:from_unit] ||= 'minutes'
66
+ from = params[:from_value].to_i.public_send(params[:from_unit].to_sym).ago
67
+ to = Time.current
68
+ (from..to)
69
+ end
57
70
  end
58
71
  end
@@ -1,6 +1,25 @@
1
1
  <h1 class="title">Transactions</h1>
2
2
 
3
- <h2 class="title is-4 has-text-grey">Last hour</h2>
3
+ <%= form_with path: transactions_path, method: :get do |f| %>
4
+ <div class="is-flex is-flex-direction-row is-justify-content-center is-align-items-center" style="gap: 1em">
5
+ <%= f.label 'From' %>
6
+ <%= f.number_field :from_value, value: params[:from_value] || 60, min: 1, class: 'input', style: 'width: 6em' %>
7
+ <div class="select">
8
+ <%= f.select :from_unit, {
9
+ "minutes" => "minutes",
10
+ "hours" => "hours",
11
+ "days" => "days",
12
+ "weeks" => "weeks",
13
+ "months" => "months",
14
+ "years" => "years"
15
+ }, {selected: params[:from_unit] || 'minutes' } %>
16
+ </div>
17
+ <span class="has-text-white-ter">ago</span>
18
+ <b>→</b>
19
+ <span class="has-text-white-ter">now</span>
20
+ <%= f.submit 'Apply', class: 'button' %>
21
+ </div>
22
+ <% end %>
4
23
  <div data-controller="transaction-chart"></div>
5
24
 
6
25
  <table class="table is-fullwidth">
@@ -9,6 +28,7 @@
9
28
  <th>Name</th>
10
29
  <th>Latency</th>
11
30
  <th>tmp</th>
31
+ <th>95p</th>
12
32
  <th>Impact</th>
13
33
  </tr>
14
34
  </thead>
@@ -18,6 +38,7 @@
18
38
  <td><%= link_to name, transaction_by_name_path(name) %></td>
19
39
  <td><%= aggregation.latency.round(2) %> ms</td>
20
40
  <td><%= aggregation.tmp.round(2) %></td>
41
+ <td><%= aggregation.percentile_95.round(2) %> ms</td>
21
42
  <td>
22
43
  <progress class="progress is-warning" value="<%= aggregation.impact %>" max="100"></progress>
23
44
  </td>
@@ -1,3 +1,3 @@
1
1
  module SolidApm
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-14 00:00:00.000000000 Z
11
+ date: 2024-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack