skylight-core 4.2.1 → 4.2.2
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 +4 -4
- data/lib/skylight/core/normalizers/graphql/base.rb +38 -13
- data/lib/skylight/core/probes/graphql.rb +53 -20
- data/lib/skylight/core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1cb7623e8186c365539b9bf9688fa52d73b7381eeb779dd3d7e7df19b3548b7
|
4
|
+
data.tar.gz: e8af5d0d9c99faa968ab1517b866af818dc788c381479815b786514061f5774d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
15
|
-
|
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
|
-
|
44
|
+
register_graphql
|
21
45
|
end
|
22
46
|
|
23
47
|
class Parse < Base
|
24
|
-
|
48
|
+
register_graphql
|
25
49
|
end
|
26
50
|
|
27
51
|
class Validate < Base
|
28
|
-
|
52
|
+
register_graphql
|
29
53
|
end
|
30
54
|
|
31
55
|
class ExecuteMultiplex < Base
|
32
|
-
|
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
|
-
|
86
|
+
register_graphql
|
62
87
|
end
|
63
88
|
|
64
89
|
class ExecuteQuery < Base
|
65
|
-
|
90
|
+
register_graphql
|
66
91
|
|
67
|
-
def normalize(trace,
|
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, "
|
103
|
+
[CAT, "graphql.#{key}: #{query_name}", nil, meta]
|
79
104
|
end
|
80
105
|
end
|
81
106
|
|
82
107
|
class ExecuteQueryLazy < ExecuteQuery
|
83
|
-
|
108
|
+
register_graphql
|
84
109
|
|
85
|
-
def normalize(trace,
|
110
|
+
def normalize(trace, _name, payload)
|
86
111
|
if payload[:query]
|
87
112
|
super
|
88
113
|
elsif payload[:multiplex]
|
89
|
-
[CAT, "
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
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.
|
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-
|
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.
|
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.
|