solid_apm 0.4.4 → 0.6.0

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: 97cdcafb0a31dea64161262374dcfd274cf450836668be0df7f4f5b5d7e70f58
4
- data.tar.gz: bd0af22ac948642e3ecb63c9b4528011ddc7df7f9ea997caee806687eba7f25b
3
+ metadata.gz: d90f515a42a990a08a88c44bb8146dfe87176c81ad8584bcf7e4a29083316c2e
4
+ data.tar.gz: a92fd226a1a96882700cea025afa4ba1d8d2356cce2dd621701149e612e9fe2c
5
5
  SHA512:
6
- metadata.gz: 9c65419c5facee2826defd7428aff0c175e9a982879b4572867370e8b0e0acd265d33f3471c111dbcf64ec192ee9fbc34290f481ad2e79be7e10f2dfb71b9408
7
- data.tar.gz: 000e091daa7ef33222824974c216d9cc4544d6be37ba6640c3eee87d18c16ced922c7b946d6368a95976f010f0cf6871892afaa229b6153ad6ba32be59f7b84c
6
+ metadata.gz: 3d0af12fc21edcb8117da1f466b440c0241ccb6995f174abf50e09e77e7fa8a32a36b1c0aa2559d55af6238dce318101bd42e38f06536f28d75499c8bdbc0a11
7
+ data.tar.gz: 5b0829667356213cda1c572c8386f902b2054143bf66b2252f2e047d9590345acaea13c4902b7dee3c04b42e6dbe73f2449d7a30197afdf5a3989628d3d1ef8b
@@ -16,7 +16,6 @@ window.Stimulus.register('transaction-chart',
16
16
  static values = { name: String }
17
17
 
18
18
  connect() {
19
- console.log('Connected')
20
19
  var options = {
21
20
  chart: {
22
21
  type: 'bar',
@@ -40,8 +39,7 @@ window.Stimulus.register('transaction-chart',
40
39
  }
41
40
  }
42
41
 
43
- let path = window.location.pathname.includes('transactions') ? 'count_by_minutes' : 'transactions/count_by_minutes';
44
- path = path + "?";
42
+ let path = "count_time_aggregations?";
45
43
  if (this.nameValue) {
46
44
  path = path + "name=" + encodeURIComponent(this.nameValue);
47
45
  }
@@ -52,6 +50,9 @@ window.Stimulus.register('transaction-chart',
52
50
  path = path + "&from_value=" + fromValue.value + "&from_unit=" + fromUnit.value;
53
51
  }
54
52
 
53
+ const base = window.location.pathname.split('/transactions')[0];
54
+ path = base + "/transactions/" + path;
55
+ path = path.replace("//", "/");
55
56
  fetch(path)
56
57
  .then(response => response.json())
57
58
  .then(data => {
@@ -46,16 +46,16 @@ module SolidApm
46
46
  render json: @spans
47
47
  end
48
48
 
49
- def count_by_minutes
49
+ def count_time_aggregations
50
50
  scope = Transaction.all.order(timestamp: :desc)
51
51
  .where(created_at: from_to_range)
52
52
 
53
+
53
54
  if params[:name].present?
54
55
  scope = scope.where(name: params[:name])
55
56
  end
56
57
 
57
- render json: scope.group_by { |t| t.created_at.beginning_of_minute }
58
- .transform_values!(&:count)
58
+ render json: aggregate(scope.select(:id, :created_at).find_each, from_to_range, intervals_count: 20).transform_values!(&:count)
59
59
  end
60
60
 
61
61
  private
@@ -67,5 +67,14 @@ module SolidApm
67
67
  to = Time.current
68
68
  (from..to)
69
69
  end
70
+
71
+ def aggregate(items, range, intervals_count: 20)
72
+ start_time = range.begin
73
+ end_time = range.end
74
+ time_range_in_seconds = (end_time - start_time).to_i
75
+ time_interval_duration_in_seconds = (time_range_in_seconds / intervals_count.to_f).round
76
+
77
+ items.chunk { |item| Time.zone.at((item.created_at.to_i) / time_interval_duration_in_seconds * time_interval_duration_in_seconds, 0) }.to_h
78
+ end
70
79
  end
71
80
  end
data/config/routes.rb CHANGED
@@ -2,9 +2,7 @@ SolidApm::Engine.routes.draw do
2
2
  root 'transactions#index'
3
3
 
4
4
  get 'transactions', to: 'transactions#index'
5
- get 'transactions/count_by_minutes',
6
- to: 'transactions#count_by_minutes',
7
- as: 'transactions_count_by_minutes',
5
+ get 'transactions/count_time_aggregations',
8
6
  default: { format: 'json' }
9
7
 
10
8
  get 'transactions/:id', to: 'transactions#show', as: 'transaction', constraints: { id: /\d+/ }
@@ -1,3 +1,3 @@
1
1
  module SolidApm
2
- VERSION = "0.4.4"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,69 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-15 00:00:00.000000000 Z
10
+ date: 2025-01-17 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '7.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '7.1'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: actionview
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '7.1'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '7.1'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: activerecord
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - "~>"
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '7.1'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - "~>"
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: '7.1'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: railties
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - "~>"
58
+ - - ">="
60
59
  - !ruby/object:Gem::Version
61
60
  version: '7.1'
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - "~>"
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '7.1'
69
68
  description: SolidApm allow you to monitor your application without any external service.
@@ -114,7 +113,6 @@ metadata:
114
113
  homepage_uri: https://github.com/Bhacaz/solid_apm
115
114
  source_code_uri: https://github.com/Bhacaz/solid_apm
116
115
  changelog_uri: https://github.com/Bhacaz/solid_apm/releases
117
- post_install_message:
118
116
  rdoc_options: []
119
117
  require_paths:
120
118
  - lib
@@ -129,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
127
  - !ruby/object:Gem::Version
130
128
  version: '0'
131
129
  requirements: []
132
- rubygems_version: 3.5.11
133
- signing_key:
130
+ rubygems_version: 3.6.2
134
131
  specification_version: 4
135
132
  summary: SolidApm is a DB base engine for Application Performance Monitoring.
136
133
  test_files: []