graphql-metrics 5.0.0 → 5.0.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: 8e2e02bf92da34c67af89cf112efe2525ca4a785f4f9169dd35320c687f5f9f4
4
- data.tar.gz: 4ec1a5b37180e5e7be02934992347053d3d4a4d2f03866975600577704e141a1
3
+ metadata.gz: 193863b65e11d92f46e0e88e31d3d07bf7bfc3b8f3f78566ab1ea03f0480a027
4
+ data.tar.gz: '029dacd1491b30aaaed8f1f29f08de8df61621690e68c437c493acd19be48c58'
5
5
  SHA512:
6
- metadata.gz: 213906efdd58b32a7cab558028fc96de33c9624f9e85ffbb572954486bb31bebc7e718f0aee4e6df4f7324d5c99c6cc1849d13a54e43bef1963a3b55517796e1
7
- data.tar.gz: 4f6309cc4cdbe2244be1d744173f795df04e955af9cef6d52111f1181c074cece01dcf226ebe20a545f3f2d41306b5eb5226e4d90ec1a7ece70656707982934a
6
+ metadata.gz: b785685753bf27bd368fcca80a9054dad9ad7d829d1a6931eb3c9ddc9090e33e7fe48a6a4d8d3305ae753078b8b47e9b6df9e65f54b497c05f15f1861ce3029e
7
+ data.tar.gz: 4bb9ab1cc43808134b16a071b4d3292c7416614f1d9d59e398c62f5843d9b53175f569385b5f4a74013a5b7817b73487f08a48736aba7228a543596a3f6271d8
@@ -0,0 +1,22 @@
1
+ name: Contributor License Agreement (CLA)
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [opened, synchronize]
6
+ issue_comment:
7
+ types: [created]
8
+
9
+ jobs:
10
+ cla:
11
+ runs-on: ubuntu-latest
12
+ if: |
13
+ (github.event.issue.pull_request
14
+ && !github.event.issue.pull_request.merged_at
15
+ && contains(github.event.comment.body, 'signed')
16
+ )
17
+ || (github.event.pull_request && !github.event.pull_request.merged)
18
+ steps:
19
+ - uses: Shopify/shopify-cla-action@v1
20
+ with:
21
+ github-token: ${{ secrets.GITHUB_TOKEN }}
22
+ cla-token: ${{ secrets.CLA_TOKEN }}
@@ -1,20 +1,20 @@
1
- name: Ruby
2
-
3
- on: [push]
4
-
1
+ name: Tests
2
+ on: [push, pull_request]
5
3
  jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
-
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ os: [ubuntu-latest]
9
+ ruby: ['2.7', '3.0', '3.1', '3.2']
10
+ gemfile: ['graphql_1.13', 'graphql_2.0']
11
+ runs-on: ${{ matrix.os }}
12
+ env:
13
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
10
14
  steps:
11
- - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
15
+ - uses: actions/checkout@v3
16
+ - uses: ruby/setup-ruby@v1
14
17
  with:
15
- ruby-version: 2.6.x
16
- - name: Build and test with Rake
17
- run: |
18
- gem install bundler
19
- bundle install --jobs 4 --retry 3
20
- bundle exec rake test
18
+ ruby-version: ${{ matrix.ruby }}
19
+ bundler-cache: true
20
+ - run: bundle exec rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.5
1
+ 3.2.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 5.0.2
2
+ -----
3
+ - [63](https://github.com/Shopify/graphql-metrics/pull/67) Reset `lex` pre-context metrics on `analyze_multiplex`.
4
+ 5.0.1
5
+ -----
6
+ - [63](https://github.com/Shopify/graphql-metrics/pull/63) Eliminate `TimedResult` objects for `trace_field`.
1
7
  5.0.0
2
8
  -----
3
9
  - [50](https://github.com/Shopify/graphql-metrics/pull/50) Capture metrics for directives and their arguments.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![](https://github.com/Shopify/graphql-metrics/workflows/Ruby/badge.svg)
4
4
 
5
- Extract as much much detail as you want from GraphQL queries, served up from your Ruby app and the [`graphql` gem](https://github.com/rmosolgo/graphql-ruby).
5
+ Extract as much detail as you want from GraphQL queries, served up from your Ruby app and the [`graphql` gem](https://github.com/rmosolgo/graphql-ruby).
6
6
  Compatible with the [`graphql-batch` gem](https://github.com/Shopify/graphql-batch), to extract batch-loaded fields resolution timings.
7
7
 
8
8
  Be sure to read the [CHANGELOG](CHANGELOG.md) to stay updated on feature additions, breaking changes made to this gem.
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ eval_gemfile("../Gemfile")
4
+
5
+ gem("graphql", "~> 1.13")
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ eval_gemfile("../Gemfile")
4
+
5
+ gem("graphql", "~> 2.0")
@@ -75,6 +75,8 @@ module GraphQL
75
75
  self[:multiplex_start_time_monotonic] = nil
76
76
  self[:parsing_start_time_offset] = nil
77
77
  self[:parsing_duration] = nil
78
+ self[:lexing_start_time_offset] = nil
79
+ self[:lexing_duration] = nil
78
80
  end
79
81
  end
80
82
 
@@ -93,10 +95,7 @@ module GraphQL
93
95
  end
94
96
 
95
97
  def capture_lexing_time
96
- # GraphQL::Query#result fires `lex` before the `execute_multiplex` event, so sometimes
97
- # `pre_context.multiplex_start_time_monotonic` isn't set.
98
- lexing_offset_time = pre_context.multiplex_start_time_monotonic || GraphQL::Metrics.current_time_monotonic
99
- timed_result = GraphQL::Metrics.time(lexing_offset_time) { yield }
98
+ timed_result = GraphQL::Metrics.time { yield }
100
99
 
101
100
  pre_context.lexing_start_time_offset = timed_result.start_time
102
101
  pre_context.lexing_duration = timed_result.duration
@@ -105,10 +104,7 @@ module GraphQL
105
104
  end
106
105
 
107
106
  def capture_parsing_time
108
- # GraphQL::Query#result fires `parse` before the `execute_multiplex` event, so sometimes
109
- # `pre_context.multiplex_start_time_monotonic` isn't set.
110
- parsing_offset_time = pre_context.multiplex_start_time_monotonic || GraphQL::Metrics.current_time_monotonic
111
- timed_result = GraphQL::Metrics.time(parsing_offset_time) { yield }
107
+ timed_result = GraphQL::Metrics.time { yield }
112
108
 
113
109
  pre_context.parsing_start_time_offset = timed_result.start_time
114
110
  pre_context.parsing_duration = timed_result.duration
@@ -166,17 +162,21 @@ module GraphQL
166
162
 
167
163
  def trace_field(context_key, data)
168
164
  ns = data[:query].context.namespace(CONTEXT_NAMESPACE)
169
- query_start_time_monotonic = ns[GraphQL::Metrics::QUERY_START_TIME_MONOTONIC]
165
+ offset_time = ns[GraphQL::Metrics::QUERY_START_TIME_MONOTONIC]
166
+ start_time = GraphQL::Metrics.current_time_monotonic
170
167
 
171
- timed_result = GraphQL::Metrics.time(query_start_time_monotonic) { yield }
168
+ result = yield
169
+
170
+ duration = GraphQL::Metrics.current_time_monotonic - start_time
171
+ time_since_offset = start_time - offset_time if offset_time
172
172
 
173
173
  path_excluding_numeric_indicies = data[:path].select { |p| p.is_a?(String) }
174
174
  ns[context_key][path_excluding_numeric_indicies] ||= []
175
175
  ns[context_key][path_excluding_numeric_indicies] << {
176
- start_time_offset: timed_result.time_since_offset, duration: timed_result.duration
176
+ start_time_offset: time_since_offset, duration: duration
177
177
  }
178
178
 
179
- timed_result.result
179
+ result
180
180
  end
181
181
  end
182
182
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Metrics
5
- VERSION = "5.0.0"
5
+ VERSION = "5.0.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Butcher
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -201,6 +201,7 @@ executables: []
201
201
  extensions: []
202
202
  extra_rdoc_files: []
203
203
  files:
204
+ - ".github/workflows/cla.yml"
204
205
  - ".github/workflows/ruby.yml"
205
206
  - ".gitignore"
206
207
  - ".rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml"
@@ -215,18 +216,19 @@ files:
215
216
  - Rakefile
216
217
  - bin/console
217
218
  - bin/setup
219
+ - gemfiles/graphql_1.13.gemfile
220
+ - gemfiles/graphql_2.0.gemfile
218
221
  - graphql_metrics.gemspec
219
222
  - lib/graphql/metrics.rb
220
223
  - lib/graphql/metrics/analyzer.rb
221
224
  - lib/graphql/metrics/instrumentation.rb
222
225
  - lib/graphql/metrics/tracer.rb
223
226
  - lib/graphql/metrics/version.rb
224
- - service.yml
225
227
  homepage: https://github.com/Shopify/graphql-metrics
226
228
  licenses:
227
229
  - MIT
228
230
  metadata: {}
229
- post_install_message:
231
+ post_install_message:
230
232
  rdoc_options: []
231
233
  require_paths:
232
234
  - lib
@@ -241,8 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
243
  - !ruby/object:Gem::Version
242
244
  version: '0'
243
245
  requirements: []
244
- rubygems_version: 3.0.3
245
- signing_key:
246
+ rubygems_version: 3.3.3
247
+ signing_key:
246
248
  specification_version: 4
247
249
  summary: GraphQL Metrics Extractor
248
250
  test_files: []
data/service.yml DELETED
@@ -1 +0,0 @@
1
- classification: library