skylight-core 4.2.2 → 4.2.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: e1cb7623e8186c365539b9bf9688fa52d73b7381eeb779dd3d7e7df19b3548b7
4
- data.tar.gz: e8af5d0d9c99faa968ab1517b866af818dc788c381479815b786514061f5774d
3
+ metadata.gz: 98240d4732a290ffb184fdc3b682f74fd167eb6061558febaef8139ac6aa4fd3
4
+ data.tar.gz: 81099a9f8a59907ebf44024645f537fca06b2e758ec65ca68253046b1d4a90e5
5
5
  SHA512:
6
- metadata.gz: 5ec93134b85fb4408a5090822838d70fa3232736af4f5693c0761cf51912f1f31989c43009e83f6b80d35a3baccbe0b7504380e4f81feac8742e903b7b16fdb1
7
- data.tar.gz: 40215e2e9b9874e05f87c315b14efd39254ba688f753ef3f520e621347c6e7ec11c6187c2bef45069e305682224f5ef6ca3c5299e9119e101a61a3453b2424b2
6
+ metadata.gz: 82b46e299d48abd8d2cb5ff4a543d324145cd55a8c2b9d9fd8413a0738aedc111bb0979f1b989aabbae2b9b894cf0b98c1f1b701390146519674165bedbe7736
7
+ data.tar.gz: 7ff7cc95fef0289039a7b2df226d0bfafcb0c9cbca53d2cbd89099c19b9a735806e2701747f002252ad387e666029718639d9001c8be3cf13abd8816ab1450cd
@@ -3,68 +3,36 @@
3
3
  module Skylight::Core
4
4
  module Probes
5
5
  module GraphQL
6
- class Probe
7
- if Gem::Version.new(::GraphQL::VERSION) >= Gem::Version.new("1.10")
8
- def install
9
- ::GraphQL::Schema.instance_eval do
10
- class << self
11
- alias_method :multiplex_without_sk, :multiplex # rubocop:disable Style/Alias
12
- end
13
-
14
- # Schema#execute also delegates to multiplex, so this is the only method
15
- # we need to override.
16
- def multiplex(*args, **kwargs)
17
- sk_add_tracer
18
- multiplex_without_sk(*args, **kwargs)
19
- end
6
+ module Instrumentation
7
+ def initialize(*, **)
8
+ super
20
9
 
21
- def sk_add_tracer
22
- Skylight::Core::Config::MUTEX.synchronize do
23
- graphql_tracer = ::GraphQL::Tracing::ActiveSupportNotificationsTracing
24
- unless tracers.include?(graphql_tracer)
25
- $stdout.puts "[SKYLIGHT::CORE] Adding tracer 'GraphQL::Tracing::ActiveSupportNotificationsTracing' to schema" # rubocop:disable Metrics/LineLength
26
- tracer(graphql_tracer)
27
- end
10
+ return unless defined?(@tracers)
28
11
 
29
- class << self
30
- # Remove the probe and reset multiplex/execute to original version
31
- # after the tracer has been added
32
- alias_method :multiplex, :multiplex_without_sk # rubocop:disable Style/Alias
33
- end
34
- end
35
- end
36
- end
12
+ unless @tracers.include?(::GraphQL::Tracing::ActiveSupportNotificationsTracing)
13
+ @tracers << ::GraphQL::Tracing::ActiveSupportNotificationsTracing
37
14
  end
38
- else
39
- def install
40
- ::GraphQL::Schema.class_eval do
41
- alias_method :multiplex_without_sk, :multiplex
15
+ end
16
+ end
42
17
 
43
- # Schema#execute also delegates to multiplex, so this is the only method
44
- # we need to override.
45
- def multiplex(*args, &block)
46
- sk_add_tracer
47
- multiplex_without_sk(*args, &block)
48
- end
18
+ class Probe
19
+ def install
20
+ tracing_klass_name = "::GraphQL::Tracing::ActiveSupportNotificationsTracing"
21
+ klasses_to_probe = %w(
22
+ ::GraphQL::Execution::Multiplex
23
+ ::GraphQL::Query
24
+ )
49
25
 
50
- def sk_add_tracer
51
- Skylight::Core::Config::MUTEX.synchronize do
52
- graphql_tracer = ::GraphQL::Tracing::ActiveSupportNotificationsTracing
53
- unless tracers.include?(graphql_tracer)
54
- $stdout.puts "[SKYLIGHT::CORE] Adding tracer 'GraphQL::Tracing::ActiveSupportNotificationsTracing' to schema" # rubocop:disable Metrics/LineLength
55
- tracers << graphql_tracer
56
- end
26
+ return unless ([tracing_klass_name] + klasses_to_probe).all?(&method(:safe_constantize))
57
27
 
58
- class << self
59
- # Remove the probe and reset multiplex/execute to original version
60
- # after the tracer has been added
61
- alias_method :multiplex, :multiplex_without_sk
62
- end
63
- end
64
- end
65
- end
28
+ klasses_to_probe.each do |klass_name|
29
+ safe_constantize(klass_name).prepend(Instrumentation)
66
30
  end
67
31
  end
32
+
33
+ def safe_constantize(klass_name)
34
+ Skylight::Core::Util::Inflector.safe_constantize(klass_name)
35
+ end
68
36
  end
69
37
  end
70
38
 
@@ -1,5 +1,5 @@
1
1
  module Skylight
2
2
  module Core
3
- VERSION = "4.2.2".freeze
3
+ VERSION = "4.2.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.2
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport