Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
fail-fast: false
matrix:
include:
- ruby: "3.4"
graphql-ruby: "2.5"
- ruby: "3.4"
graphql-ruby: "2.4"
- ruby: "3.3"
graphql-ruby: "2.3"
- ruby: "3.3"
graphql-ruby: "2.2"
- ruby: "3.2"
Expand Down
12 changes: 12 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ end
appraise "graphql-2.2" do
gem "graphql", "~> 2.2.0"
end

appraise "graphql-2.3" do
gem "graphql", "~> 2.3.0"
end

appraise "graphql-2.4" do
gem "graphql", "~> 2.4.0"
end

appraise "graphql-2.5" do
gem "graphql", "~> 2.5.0"
end
14 changes: 14 additions & 0 deletions gemfiles/graphql_2.3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "graphql", "~> 2.3.0"

group :development, :test do
gem "pry"
gem "pry-inline"
gem "pry-byebug", platform: :mri
gem "graphql-batch"
end

gemspec path: "../"
80 changes: 80 additions & 0 deletions gemfiles/graphql_2.3.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
PATH
remote: ..
specs:
yabeda-graphql (0.2.3)
graphql (>= 1.9, < 3)
yabeda (~> 0.2)

GEM
remote: https://rubygems.org/
specs:
anyway_config (2.7.2)
ruby-next-core (~> 1.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
base64 (0.3.0)
byebug (12.0.0)
coderay (1.1.3)
concurrent-ruby (1.3.5)
diff-lcs (1.6.2)
dry-initializer (3.2.0)
fiber-storage (1.0.1)
graphql (2.3.22)
base64
fiber-storage
graphql-batch (0.6.0)
graphql (>= 1.12.18, < 3)
promise.rb (~> 0.7.2)
method_source (1.1.0)
promise.rb (0.7.4)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.11.0)
byebug (~> 12.0)
pry (>= 0.13, < 0.16)
pry-inline (1.0.7)
pry (> 0.10.0)
unicode (~> 0.4.4)
rake (13.3.0)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
ruby-next-core (1.1.2)
thor (1.3.2)
unicode (0.4.4.5)
yabeda (0.13.1)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
appraisal
bundler
graphql (~> 2.3.0)
graphql-batch
pry
pry-byebug
pry-inline
rake (~> 13.0)
rspec (~> 3.0)
yabeda-graphql!

BUNDLED WITH
2.5.6
14 changes: 14 additions & 0 deletions gemfiles/graphql_2.4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "graphql", "~> 2.4.0"

group :development, :test do
gem "pry"
gem "pry-inline"
gem "pry-byebug", platform: :mri
gem "graphql-batch"
end

gemspec path: "../"
82 changes: 82 additions & 0 deletions gemfiles/graphql_2.4.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
PATH
remote: ..
specs:
yabeda-graphql (0.2.3)
graphql (>= 1.9, < 3)
yabeda (~> 0.2)

GEM
remote: https://rubygems.org/
specs:
anyway_config (2.7.2)
ruby-next-core (~> 1.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
base64 (0.3.0)
byebug (12.0.0)
coderay (1.1.3)
concurrent-ruby (1.3.5)
diff-lcs (1.6.2)
dry-initializer (3.2.0)
fiber-storage (1.0.1)
graphql (2.4.17)
base64
fiber-storage
logger
graphql-batch (0.6.0)
graphql (>= 1.12.18, < 3)
promise.rb (~> 0.7.2)
logger (1.7.0)
method_source (1.1.0)
promise.rb (0.7.4)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.11.0)
byebug (~> 12.0)
pry (>= 0.13, < 0.16)
pry-inline (1.0.7)
pry (> 0.10.0)
unicode (~> 0.4.4)
rake (13.3.0)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
ruby-next-core (1.1.2)
thor (1.3.2)
unicode (0.4.4.5)
yabeda (0.13.1)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
appraisal
bundler
graphql (~> 2.4.0)
graphql-batch
pry
pry-byebug
pry-inline
rake (~> 13.0)
rspec (~> 3.0)
yabeda-graphql!

BUNDLED WITH
2.5.6
14 changes: 14 additions & 0 deletions gemfiles/graphql_2.5.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "graphql", "~> 2.5.0"

group :development, :test do
gem "pry"
gem "pry-inline"
gem "pry-byebug", platform: :mri
gem "graphql-batch"
end

gemspec path: "../"
82 changes: 82 additions & 0 deletions gemfiles/graphql_2.5.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
PATH
remote: ..
specs:
yabeda-graphql (0.2.3)
graphql (>= 1.9, < 3)
yabeda (~> 0.2)

GEM
remote: https://rubygems.org/
specs:
anyway_config (2.7.2)
ruby-next-core (~> 1.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
base64 (0.3.0)
byebug (12.0.0)
coderay (1.1.3)
concurrent-ruby (1.3.5)
diff-lcs (1.6.2)
dry-initializer (3.2.0)
fiber-storage (1.0.1)
graphql (2.5.9)
base64
fiber-storage
logger
graphql-batch (0.6.0)
graphql (>= 1.12.18, < 3)
promise.rb (~> 0.7.2)
logger (1.7.0)
method_source (1.1.0)
promise.rb (0.7.4)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.11.0)
byebug (~> 12.0)
pry (>= 0.13, < 0.16)
pry-inline (1.0.7)
pry (> 0.10.0)
unicode (~> 0.4.4)
rake (13.3.0)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
ruby-next-core (1.1.2)
thor (1.3.2)
unicode (0.4.4.5)
yabeda (0.13.1)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
appraisal
bundler
graphql (~> 2.5.0)
graphql-batch
pry
pry-byebug
pry-inline
rake (~> 13.0)
rspec (~> 3.0)
yabeda-graphql!

BUNDLED WITH
2.5.23
16 changes: 14 additions & 2 deletions lib/yabeda/graphql.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
require "graphql/version"

require "yabeda"
require "yabeda/graphql/version"
require "yabeda/graphql/yabeda_tracing"
require "yabeda/graphql/instrumentation"

if Gem::Version.new(::GraphQL::VERSION) < Gem::Version.new("2.2.0")
require "yabeda/graphql/legacy/yabeda_tracing"
require "yabeda/graphql/legacy/instrumentation"
end

module Yabeda
module GraphQL
class Error < StandardError; end
Expand Down Expand Up @@ -30,8 +37,13 @@ class Error < StandardError; end
end

def self.use(schema)
schema.instrument(:query, Instrumentation.new)
schema.use YabedaTracing, trace_scalars: true
if Gem::Version.new(::GraphQL::VERSION) >= Gem::Version.new( "2.2.0")
schema.trace_with Yabeda::GraphQL::Instrumentation
schema.trace_with Yabeda::GraphQL::YabedaTracing
else
schema.instrument :query, Legacy::Instrumentation.new
schema.use Legacy::YabedaTracing, trace_scalars: true
end
end
end
end
20 changes: 11 additions & 9 deletions lib/yabeda/graphql/instrumentation.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
module Yabeda
module GraphQL
class Instrumentation
def before_query(query)
reset_cache!(query)
end

def after_query(query)
cache(query).each do |_path, options|
Yabeda.graphql.field_resolve_runtime.measure(options[:tags], options[:duration])
Yabeda.graphql.fields_request_count.increment(options[:tags])
module Instrumentation
def execute_multiplex(multiplex:)
queries = multiplex.queries
queries.each { |query| reset_cache!(query) }
result = super
queries.each do |query|
cache(query).each do |_path, options|
Yabeda.graphql.field_resolve_runtime.measure(options[:tags], options[:duration])
Yabeda.graphql.fields_request_count.increment(options[:tags])
end
end
result
end

private
Expand Down
Loading