optic-rails 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9410ea4eb57b65685d90e10085ae84f5e40607ed9f1a1016c147c1c3c231efe
4
- data.tar.gz: adc15f1add9ac36ccdf2ca8be14a369ab2ba6475072e2298c963d52ddd597d97
3
+ metadata.gz: 8f787a6d3e1f1ff640839f94a3d37af5983d4649e8027e38deb49eead5c06957
4
+ data.tar.gz: c163087d65a95951548d14f0aa7bb091e828672e45d4aa4a91190dcfd48298e9
5
5
  SHA512:
6
- metadata.gz: 732f7902ece59b40ec446b17615836b490ba2e94bea9f72ff0b75439274e878f32d85fd057d6854077314256141aa6b8e57dd485cc5c61f72732704097a3b31a
7
- data.tar.gz: a53b1d9fb359101ae9a51eb90a0e32c292440a19b951aae377c17a328b591e03f84df378fc15589fdb98c6f6acbd705dd5654d47176d40736059552093c2f063
6
+ metadata.gz: 7e39ff209e85dc27916dba16ed61a757cbd551ab91d448e36a08fd6b2ba02009098e4ec2126622d478496a7c64f05b8d2568a3ad0ad4fed35f5639debc6be956
7
+ data.tar.gz: 2d9ec9f9bf07ecece630d508b92d16f7c111d58406a59964c775e264d553fc736e5dcce50ef067546edb85b5efac4f7e60cdb2a36fa468a9f1a47bac86c857e4
@@ -5,33 +5,44 @@ require "optic/rails/railtie"
5
5
  module Optic
6
6
  module Rails
7
7
  class << self
8
- def entities
8
+ def entities(logger)
9
9
  with_connection do
10
10
  {
11
11
  schema_version: ActiveRecord::Migrator.current_version,
12
12
  entities: active_record_klasses.map do |klass|
13
- {
14
- name: klass.name,
15
- table_name: klass.table_name,
16
- entity_attribute_names: klass.attribute_names,
17
- table_exists: klass.table_exists?,
18
- associations: klass.reflect_on_all_associations.map do |reflection|
19
- {
20
- name: reflection.name,
21
- macro: reflection.macro,
22
- options: reflection.options.map { |k, v| [k, v.to_s] }.to_h,
23
- klass_name: reflection.options[:polymorphic] ? nil : reflection.klass.name,
24
- }
25
- end
26
- }
27
- end
13
+ begin
14
+ logger.debug "Inspecting entity #{klass}"
15
+ {
16
+ name: klass.name,
17
+ table_name: klass.table_name,
18
+ entity_attribute_names: klass.attribute_names,
19
+ table_exists: klass.table_exists?,
20
+ associations: klass.reflect_on_all_associations.map do |reflection|
21
+ begin
22
+ logger.debug "Inspecting association #{klass}/#{reflection.name}"
23
+ {
24
+ name: reflection.name,
25
+ macro: reflection.macro,
26
+ options: reflection.options.map { |k, v| [k, v.to_s] }.to_h,
27
+ klass_name: reflection.options[:polymorphic] ? nil : reflection.klass.name,
28
+ }
29
+ rescue
30
+ nil
31
+ end
32
+ end.compact
33
+ }
34
+ rescue
35
+ nil
36
+ end
37
+ end.compact
28
38
  }
29
39
  end
30
40
  end
31
41
 
32
- def metrics(instructions)
42
+ def metrics(logger, instructions)
33
43
  with_connection do |connection|
34
44
  instructions.map do |instruction|
45
+ logger.debug "Gathering metrics for metric_configuration_id = #{instruction['metric_configuration_id']}"
35
46
  name = instruction["entity"]
36
47
  entity = entity_for_entity_name name
37
48
 
@@ -66,9 +66,9 @@ module Optic
66
66
 
67
67
  case command
68
68
  when "request_schema"
69
- client.perform "schema", message: Optic::Rails.entities
69
+ client.perform "schema", message: Optic::Rails.entities(logger)
70
70
  when "request_metrics"
71
- client.perform "metrics", message: Optic::Rails.metrics(message["instructions"])
71
+ client.perform "metrics", message: Optic::Rails.metrics(logger, message["instructions"])
72
72
  else
73
73
  logger.warn "Optic agent got unknown command: #{command}"
74
74
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Optic
4
4
  module Rails
5
- VERSION = "1.3.2"
5
+ VERSION = "1.3.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optic-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Vaynshtok
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_cable_client