skylight-core 4.2.1 → 4.2.2

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: 8c4b136b3f461ff94a6d693a2b1aca9c63c178e4bd3db96101ad667cfe54441e
4
- data.tar.gz: fc5d2e143f1c03184d8ae05cbca803c5e27320ed070a04f7eff13101f4b29023
3
+ metadata.gz: e1cb7623e8186c365539b9bf9688fa52d73b7381eeb779dd3d7e7df19b3548b7
4
+ data.tar.gz: e8af5d0d9c99faa968ab1517b866af818dc788c381479815b786514061f5774d
5
5
  SHA512:
6
- metadata.gz: 9e9ed8c974221845ad2724cbedf5deea98a51519a3d098b6d9f5309e6660f6f0327ad6435fd5bf8e420bc3b474e377ab732e4a6fa90b80fac53f222ec16996e2
7
- data.tar.gz: dff09e0c589d7e2d84eba7c7e5baf8edc294dd44717a5fda4cc2d1effeb9e58adb28fce645176c4d6fcd7c48a4c5ae30db6145e9c5d97367ad92e8e0c7101a24
6
+ metadata.gz: 5ec93134b85fb4408a5090822838d70fa3232736af4f5693c0761cf51912f1f31989c43009e83f6b80d35a3baccbe0b7504380e4f81feac8742e903b7b16fdb1
7
+ data.tar.gz: 40215e2e9b9874e05f87c315b14efd39254ba688f753ef3f520e621347c6e7ec11c6187c2bef45069e305682224f5ef6ca3c5299e9119e101a61a3453b2424b2
@@ -11,25 +11,50 @@ module Skylight::Core::Normalizers::GraphQL
11
11
  ANONYMOUS = "[anonymous]".freeze
12
12
  CAT = "app.graphql".freeze
13
13
 
14
- def normalize(_trace, name, _payload)
15
- [CAT, name, nil]
14
+ if defined?(::GraphQL::VERSION) && Gem::Version.new(::GraphQL::VERSION) >= Gem::Version.new("1.10")
15
+ def self.register_graphql
16
+ register("#{key}.graphql")
17
+ end
18
+ else
19
+ def self.register_graphql
20
+ register("graphql.#{key}")
21
+ end
22
+ end
23
+
24
+ def self.inherited(klass)
25
+ klass.const_set(:KEY, klass.name.demodulize.underscore.freeze)
26
+ end
27
+
28
+ def self.key
29
+ self::KEY
16
30
  end
31
+
32
+ def normalize(_trace, _name, _payload)
33
+ [CAT, "graphql.#{key}", nil]
34
+ end
35
+
36
+ private
37
+
38
+ def key
39
+ self.class.key
40
+ end
17
41
  end
18
42
 
19
43
  class Lex < Base
20
- register "graphql.lex"
44
+ register_graphql
21
45
  end
22
46
 
23
47
  class Parse < Base
24
- register "graphql.parse"
48
+ register_graphql
25
49
  end
26
50
 
27
51
  class Validate < Base
28
- register "graphql.validate"
52
+ register_graphql
29
53
  end
30
54
 
31
55
  class ExecuteMultiplex < Base
32
- register "graphql.execute_multiplex"
56
+ register_graphql
57
+
33
58
  def normalize_after(trace, _span, _name, payload)
34
59
  # This is in normalize_after because the queries may not have
35
60
  # an assigned operation name before they are executed.
@@ -58,13 +83,13 @@ module Skylight::Core::Normalizers::GraphQL
58
83
  end
59
84
 
60
85
  class AnalyzeQuery < Base
61
- register "graphql.analyze_query"
86
+ register_graphql
62
87
  end
63
88
 
64
89
  class ExecuteQuery < Base
65
- register "graphql.execute_query"
90
+ register_graphql
66
91
 
67
- def normalize(trace, name, payload)
92
+ def normalize(trace, _name, payload)
68
93
  query_name = payload[:query]&.operation_name || ANONYMOUS
69
94
 
70
95
  if query_name == ANONYMOUS
@@ -75,18 +100,18 @@ module Skylight::Core::Normalizers::GraphQL
75
100
  # but in the case of a single query, it will be the same value anyway.
76
101
  trace.endpoint = "graphql:#{query_name}"
77
102
 
78
- [CAT, "#{name}: #{query_name}", nil, meta]
103
+ [CAT, "graphql.#{key}: #{query_name}", nil, meta]
79
104
  end
80
105
  end
81
106
 
82
107
  class ExecuteQueryLazy < ExecuteQuery
83
- register "graphql.execute_query_lazy"
108
+ register_graphql
84
109
 
85
- def normalize(trace, name, payload)
110
+ def normalize(trace, _name, payload)
86
111
  if payload[:query]
87
112
  super
88
113
  elsif payload[:multiplex]
89
- [CAT, "#{name}.multiplex", nil]
114
+ [CAT, "graphql.#{key}.multiplex", nil]
90
115
  end
91
116
  end
92
117
  end
@@ -4,29 +4,62 @@ module Skylight::Core
4
4
  module Probes
5
5
  module GraphQL
6
6
  class Probe
7
- def install
8
- ::GraphQL::Schema.class_eval do
9
- alias_method :multiplex_without_sk, :multiplex
10
-
11
- # Schema#execute also delegates to multiplex, so this is the only method
12
- # we need to override.
13
- def multiplex(*args, &block)
14
- sk_add_tracer
15
- multiplex_without_sk(*args, &block)
16
- end
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
20
+
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
17
28
 
18
- def sk_add_tracer
19
- Skylight::Core::Config::MUTEX.synchronize do
20
- graphql_tracer = ::GraphQL::Tracing::ActiveSupportNotificationsTracing
21
- unless tracers.include?(graphql_tracer)
22
- $stdout.puts "[SKYLIGHT::CORE] Adding tracer 'GraphQL::Tracing::ActiveSupportNotificationsTracing' to schema"
23
- tracers << graphql_tracer
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
24
34
  end
35
+ end
36
+ end
37
+ end
38
+ else
39
+ def install
40
+ ::GraphQL::Schema.class_eval do
41
+ alias_method :multiplex_without_sk, :multiplex
42
+
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
49
+
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
25
57
 
26
- class << self
27
- # Remove the probe and reset multiplex/execute to original version
28
- # after the tracer has been added
29
- alias_method :multiplex, :multiplex_without_sk
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
30
63
  end
31
64
  end
32
65
  end
@@ -1,5 +1,5 @@
1
1
  module Skylight
2
2
  module Core
3
- VERSION = "4.2.1".freeze
3
+ VERSION = "4.2.2".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.1
4
+ version: 4.2.2
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-01-14 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 3.0.6
272
+ rubygems_version: 3.0.3
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: The core methods of the Skylight profiler.