yabeda-graphql 0.2.2 → 0.3.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.
@@ -0,0 +1,63 @@
1
+ module Yabeda
2
+ module GraphQL
3
+ module YabedaTracing
4
+ def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
5
+ start = ::Process.clock_gettime ::Process::CLOCK_MONOTONIC
6
+ result = block.call
7
+ duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start
8
+
9
+ tags = extract_field_tags(field)
10
+ path = query.context.current_path
11
+
12
+ if path.length == 1
13
+ return result if query.schema.lazy?(result)
14
+
15
+ if query.query?
16
+ instrument_query_execution(tags)
17
+ elsif query.mutation?
18
+ instrument_mutation_execution(tags)
19
+ elsif query.subscription?
20
+ # Not implemented yet
21
+ end
22
+ else
23
+ instrument_field_execution(query, path, tags, duration)
24
+ end
25
+
26
+ result
27
+ end
28
+
29
+ def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
30
+ execute_field(field: field, query: query, ast_node: ast_node, arguments: arguments, object: object, &block)
31
+ end
32
+
33
+ def extract_field_tags(field)
34
+ owner = field.respond_to?(:owner) ? field.owner : field.metadata[:type_class].owner
35
+ {
36
+ type: owner.graphql_name,
37
+ field: field.graphql_name,
38
+ deprecated: !field.deprecation_reason.nil?,
39
+ }
40
+ end
41
+
42
+ def instrument_field_execution(query, path, tags, duration)
43
+ cache(query)[path][:tags] = tags
44
+ cache(query)[path][:duration] += duration
45
+ end
46
+
47
+ def instrument_mutation_execution(tags)
48
+ tags = { name: tags[:field], deprecated: tags[:deprecated] }
49
+ Yabeda.graphql.mutation_fields_count.increment(tags)
50
+ end
51
+
52
+ def instrument_query_execution(tags)
53
+ tags = { name: tags[:field], deprecated: tags[:deprecated] }
54
+ Yabeda.graphql.query_fields_count.increment(tags)
55
+ end
56
+
57
+ def cache(query)
58
+ query.context.namespace(Yabeda::GraphQL)[:field_call_cache]
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -1,6 +1,6 @@
1
1
  require "yabeda"
2
2
  require "yabeda/graphql/version"
3
- require "yabeda/graphql/tracing"
3
+ require "yabeda/graphql/yabeda_tracing"
4
4
  require "yabeda/graphql/instrumentation"
5
5
 
6
6
  module Yabeda
@@ -30,8 +30,8 @@ module Yabeda
30
30
  end
31
31
 
32
32
  def self.use(schema)
33
- schema.instrument(:query, Instrumentation.new)
34
- schema.use Tracing, trace_scalars: true
33
+ schema.trace_with Yabeda::GraphQL::Instrumentation
34
+ schema.trace_with Yabeda::GraphQL::YabedaTracing
35
35
  end
36
36
  end
37
37
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_runtime_dependency "yabeda", "~> 0.2"
27
- spec.add_runtime_dependency "graphql", ">= 1.9", "< 3"
27
+ spec.add_runtime_dependency "graphql", "~> 2.2"
28
28
 
29
29
  spec.add_development_dependency "bundler"
30
30
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: yabeda
@@ -28,22 +27,16 @@ dependencies:
28
27
  name: graphql
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '1.9'
34
- - - "<"
30
+ - - "~>"
35
31
  - !ruby/object:Gem::Version
36
- version: '3'
32
+ version: '2.2'
37
33
  type: :runtime
38
34
  prerelease: false
39
35
  version_requirements: !ruby/object:Gem::Requirement
40
36
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '1.9'
44
- - - "<"
37
+ - - "~>"
45
38
  - !ruby/object:Gem::Version
46
- version: '3'
39
+ version: '2.2'
47
40
  - !ruby/object:Gem::Dependency
48
41
  name: bundler
49
42
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +101,7 @@ executables: []
108
101
  extensions: []
109
102
  extra_rdoc_files: []
110
103
  files:
111
- - ".github/workflows/build-release.yml"
104
+ - ".github/workflows/release.yml"
112
105
  - ".github/workflows/test.yml"
113
106
  - ".gitignore"
114
107
  - ".rspec"
@@ -122,23 +115,19 @@ files:
122
115
  - bin/console
123
116
  - bin/setup
124
117
  - gemfiles/.bundle/config
125
- - gemfiles/graphql_1.10.gemfile
126
- - gemfiles/graphql_1.10.gemfile.lock
127
- - gemfiles/graphql_1.11.gemfile
128
- - gemfiles/graphql_1.11.gemfile.lock
129
- - gemfiles/graphql_1.12.gemfile
130
- - gemfiles/graphql_1.12.gemfile.lock
131
- - gemfiles/graphql_1.13.gemfile
132
- - gemfiles/graphql_1.13.gemfile.lock
133
- - gemfiles/graphql_1.9.gemfile
134
- - gemfiles/graphql_1.9.gemfile.lock
135
- - gemfiles/graphql_2.0.gemfile
136
- - gemfiles/graphql_2.0.gemfile.lock
118
+ - gemfiles/graphql_2.2.gemfile
119
+ - gemfiles/graphql_2.2.gemfile.lock
120
+ - gemfiles/graphql_2.3.gemfile
121
+ - gemfiles/graphql_2.3.gemfile.lock
122
+ - gemfiles/graphql_2.4.gemfile
123
+ - gemfiles/graphql_2.4.gemfile.lock
124
+ - gemfiles/graphql_2.5.gemfile
125
+ - gemfiles/graphql_2.5.gemfile.lock
137
126
  - grafana-dashboard.json
138
127
  - lib/yabeda/graphql.rb
139
128
  - lib/yabeda/graphql/instrumentation.rb
140
- - lib/yabeda/graphql/tracing.rb
141
129
  - lib/yabeda/graphql/version.rb
130
+ - lib/yabeda/graphql/yabeda_tracing.rb
142
131
  - yabeda-graphql-logo.png
143
132
  - yabeda-graphql.gemspec
144
133
  homepage: http://github.com/yabeda-rb/yabeda-graphql
@@ -146,7 +135,6 @@ licenses:
146
135
  - MIT
147
136
  metadata:
148
137
  homepage_uri: http://github.com/yabeda-rb/yabeda-graphql
149
- post_install_message:
150
138
  rdoc_options: []
151
139
  require_paths:
152
140
  - lib
@@ -161,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
149
  - !ruby/object:Gem::Version
162
150
  version: '0'
163
151
  requirements: []
164
- rubygems_version: 3.1.6
165
- signing_key:
152
+ rubygems_version: 3.6.9
166
153
  specification_version: 4
167
154
  summary: Collects metrics to monitor execution of your GraphQL queries
168
155
  test_files: []
@@ -1,14 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "graphql", "~> 1.10.0"
6
-
7
- group :development, :test do
8
- gem "pry"
9
- gem "pry-inline"
10
- gem "pry-byebug", platform: :mri
11
- gem "graphql-batch"
12
- end
13
-
14
- gemspec path: "../"
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.0.4)
22
- graphql (1.10.14)
23
- graphql-batch (0.5.1)
24
- graphql (>= 1.10, < 3)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.14.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.8.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.10)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 1.10.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.0.4)
22
- graphql (1.11.10)
23
- graphql-batch (0.5.1)
24
- graphql (>= 1.10, < 3)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.13.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.9.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.13.0)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 1.11.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10
@@ -1,14 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "graphql", "~> 1.12.0"
6
-
7
- group :development, :test do
8
- gem "pry"
9
- gem "pry-inline"
10
- gem "pry-byebug", platform: :mri
11
- gem "graphql-batch"
12
- end
13
-
14
- gemspec path: "../"
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.1.1)
22
- graphql (1.12.24)
23
- graphql-batch (0.5.1)
24
- graphql (>= 1.10, < 3)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.13.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.9.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.13.0)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 1.12.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.1.1)
22
- graphql (1.13.11)
23
- graphql-batch (0.5.1)
24
- graphql (>= 1.10, < 3)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.13.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.9.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.13.0)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- x86_64-linux
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 1.13.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.0.4)
22
- graphql (1.9.21)
23
- graphql-batch (0.4.3)
24
- graphql (>= 1.3, < 2)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.14.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.8.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.10)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 1.9.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- yabeda-graphql (0.2.1)
5
- graphql (>= 1.9, < 3)
6
- yabeda (~> 0.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- anyway_config (2.3.0)
12
- ruby-next-core (>= 0.14.0)
13
- appraisal (2.4.1)
14
- bundler
15
- rake
16
- thor (>= 0.14.0)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- concurrent-ruby (1.1.10)
20
- diff-lcs (1.5.0)
21
- dry-initializer (3.1.1)
22
- graphql (2.0.5)
23
- graphql-batch (0.5.1)
24
- graphql (>= 1.10, < 3)
25
- promise.rb (~> 0.7.2)
26
- method_source (1.0.0)
27
- promise.rb (0.7.4)
28
- pry (0.13.1)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
- pry-byebug (3.9.0)
32
- byebug (~> 11.0)
33
- pry (~> 0.13.0)
34
- pry-inline (1.0.7)
35
- pry (> 0.10.0)
36
- unicode (~> 0.4.4)
37
- rake (13.0.6)
38
- rspec (3.11.0)
39
- rspec-core (~> 3.11.0)
40
- rspec-expectations (~> 3.11.0)
41
- rspec-mocks (~> 3.11.0)
42
- rspec-core (3.11.0)
43
- rspec-support (~> 3.11.0)
44
- rspec-expectations (3.11.0)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.11.0)
47
- rspec-mocks (3.11.1)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-support (3.11.0)
51
- ruby-next-core (0.15.0)
52
- thor (1.2.1)
53
- unicode (0.4.4.4)
54
- yabeda (0.11.0)
55
- anyway_config (>= 1.0, < 3)
56
- concurrent-ruby
57
- dry-initializer
58
-
59
- PLATFORMS
60
- x86_64-linux
61
-
62
- DEPENDENCIES
63
- appraisal
64
- bundler
65
- graphql (~> 2.0.0)
66
- graphql-batch
67
- pry
68
- pry-byebug
69
- pry-inline
70
- rake (~> 13.0)
71
- rspec (~> 3.0)
72
- yabeda-graphql!
73
-
74
- BUNDLED WITH
75
- 2.3.10