graphql-opentracing 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -14
- data/README.md +1 -8
- data/graphql-opentracing.gemspec +0 -1
- data/lib/graphql/opentracing/version.rb +1 -1
- data/lib/graphql/tracer.rb +26 -22
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d648af2c21ad166ce60ccdaa6684367130a830c
|
4
|
+
data.tar.gz: 488781fda3b16de2272388eb55bd5bff44f2f6a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51132d0527b462918eee0e0897ad954f4a9a55a505f28c75d2f3d8380062b64e6555090e3c201040e8d5450a100132c4fa78a46d4b8b8bb5e3d2b2d92a053f5a
|
7
|
+
data.tar.gz: a30fbb76b03ec618cf4254da896e0d9e7f3777a64007268dcf6fa24177a6c266740159327ea7cf873a26ed58c16cccfcacb9534af947c6a00589454a16ac8421
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql-opentracing (0.
|
5
|
-
activesupport
|
4
|
+
graphql-opentracing (0.2.0)
|
6
5
|
opentracing (~> 0.5.0)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
|
-
activesupport (5.2.3)
|
12
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>= 0.7, < 2)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
concurrent-ruby (1.1.5)
|
17
10
|
diff-lcs (1.3)
|
18
11
|
graphql (1.9.12)
|
19
|
-
i18n (1.6.0)
|
20
|
-
concurrent-ruby (~> 1.0)
|
21
|
-
minitest (5.11.3)
|
22
12
|
opentracing (0.5.0)
|
23
13
|
rake (10.5.0)
|
24
14
|
rspec (3.8.0)
|
@@ -34,9 +24,6 @@ GEM
|
|
34
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
25
|
rspec-support (~> 3.8.0)
|
36
26
|
rspec-support (3.8.2)
|
37
|
-
thread_safe (0.3.6)
|
38
|
-
tzinfo (1.2.5)
|
39
|
-
thread_safe (~> 0.1)
|
40
27
|
|
41
28
|
PLATFORMS
|
42
29
|
ruby
|
data/README.md
CHANGED
@@ -38,19 +38,12 @@ tracer(GraphQL::Tracing::ActiveSupportNotificationsTracing)
|
|
38
38
|
Under the hood this gem subscribes to graphql instrumentation events through the ActiveSupport notifications framework. If you find the number of spans too noisy you can control which spans are reported though a callback like:
|
39
39
|
```
|
40
40
|
GraphQl::Tracer.instrument(
|
41
|
+
schema: MyGQLSchema,
|
41
42
|
tracer: tracer,
|
42
43
|
ignore_request: ->(name, started, finished, id, data) { !name.include? 'execute_query' }
|
43
44
|
)
|
44
45
|
```
|
45
46
|
|
46
|
-
If you have a bespoke way of passing errors in the response that is not part of context errors you can detect errors for tagging your spans through a callback:
|
47
|
-
```
|
48
|
-
GraphQl::Tracer.instrument(
|
49
|
-
tracer: tracer,
|
50
|
-
check_errors: ->(name, started, finished, id, data) { data[:context] == "whatever" }
|
51
|
-
)
|
52
|
-
```
|
53
|
-
|
54
47
|
## Development
|
55
48
|
|
56
49
|
After checking out the repo, run `bundle install` to install dependencies. Then, run `rspec` to run the tests.
|
data/graphql-opentracing.gemspec
CHANGED
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
spec.add_dependency "opentracing", "~> 0.5.0"
|
32
|
-
spec.add_dependency "activesupport"
|
33
32
|
spec.add_development_dependency "graphql"
|
34
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
35
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/graphql/tracer.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'graphql/opentracing/version'
|
2
|
-
require 'active_support'
|
3
4
|
|
4
5
|
module GraphQL
|
5
6
|
module Tracer
|
6
|
-
class IncompatibleGemVersion < StandardError; end
|
7
|
+
class IncompatibleGemVersion < StandardError; end
|
7
8
|
|
8
9
|
class << self
|
9
10
|
attr_accessor :ignore_request, :tracer
|
10
11
|
|
11
|
-
IgnoreRequest = ->(_name,
|
12
|
-
|
13
|
-
def instrument(tracer: OpenTracing.global_tracer,
|
12
|
+
IgnoreRequest = ->(_name, _metadata) { false }
|
13
|
+
|
14
|
+
def instrument(schema: nil, tracer: OpenTracing.global_tracer,
|
15
|
+
ignore_request: IgnoreRequest)
|
14
16
|
begin
|
15
17
|
require 'graphql'
|
16
18
|
rescue LoadError
|
@@ -18,10 +20,10 @@ module GraphQL
|
|
18
20
|
end
|
19
21
|
raise IncompatibleGemVersion unless compatible_version?
|
20
22
|
|
23
|
+
@schema = schema
|
21
24
|
@ignore_request = ignore_request
|
22
|
-
@check_errors = check_errors
|
23
25
|
@tracer = tracer
|
24
|
-
|
26
|
+
install_tracer
|
25
27
|
end
|
26
28
|
|
27
29
|
def compatible_version?
|
@@ -29,21 +31,23 @@ module GraphQL
|
|
29
31
|
Gem::Version.new(GraphQL::VERSION) >= Gem::Version.new('1.7.0')
|
30
32
|
end
|
31
33
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
def install_tracer
|
35
|
+
@schema.tracer self if @schema
|
36
|
+
end
|
37
|
+
|
38
|
+
def trace(key, metadata)
|
39
|
+
return yield if @ignore_request.call(key, metadata)
|
40
|
+
|
41
|
+
@tracer.start_active_span("graphql.#{key}", tags: {
|
42
|
+
'component' => 'ruby-graphql',
|
43
|
+
'span.kind' => 'server'
|
44
|
+
}) do |scope|
|
45
|
+
begin
|
46
|
+
yield
|
47
|
+
rescue StandardError
|
48
|
+
scope.span.set_tag('error', true)
|
49
|
+
raise
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-opentracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Fischer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentracing
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: graphql
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|