README.md in graphql-metrics-4.0.6 vs README.md in graphql-metrics-4.1.0
- old
+ new
@@ -5,10 +5,13 @@
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).
Compatible with the [`graphql-batch` gem](https://github.com/Shopify/graphql-batch), to extract batch-loaded fields resolution timings.
Be sure to read the [CHANGELOG](CHANGELOG.md) to stay updated on feature additions, breaking changes made to this gem.
+**NOTE**: Not tested with graphql-ruby's multiplexing feature. Metrics may not
+be accurate if you execute multiple operations at once.
+
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -42,17 +45,15 @@
this data is simply stored on the GraphQL::Query context, under a namespace to avoid collisions with other analyzers
etc.
What you do with these captured metrics is up to you!
-**NOTE**: Runtime metrics on for queries (like `query_duration`, `parsing_start_time_offset` etc.) as well as field
-resolver timings (like `resolver_timings`, `lazy_resolver_timings`) may not be present in the extracted `metrics` hash,
+**NOTE**: If any non-`graphql-ruby` gem-related exceptions occur in your application during query document
+parsing and validation, **runtime metrics** for queries (like `query_duration`, `parsing_start_time_offset` etc.) as well as field
+resolver timings (like `resolver_timings`, `lazy_resolver_timings`) **may not be present** in the extracted `metrics` hash,
even if you opt to collect them by using `GraphQL::Metrics::Analyzer` and `GraphQL::Metrics::Tracer`.
-More specifically, if any non-`graphql-ruby` gem-related exceptions occur in your application during query document
-parsing and validation runtime metrics will not be added to the `metrics` hash.
-
### Define your own analyzer subclass
```ruby
class SimpleAnalyzer < GraphQL::Metrics::Analyzer
ANALYZER_NAMESPACE = :simple_analyzer_namespace
@@ -72,10 +73,12 @@
# {
# operation_type: "query",
# operation_name: "PostDetails",
# query_start_time: 1573833076.027327,
# query_duration: 2.0207119999686256,
+ # lexing_start_time_offset: 0.0010339999571442604,
+ # lexing_duration: 0.0008190000080503523,
# parsing_start_time_offset: 0.0010339999571442604,
# parsing_duration: 0.0008190000080503523,
# validation_start_time_offset: 0.0030819999519735575,
# validation_duration: 0.01704599999357015,
# analysis_start_time_offset: 0.0010339999571442604,
@@ -179,13 +182,10 @@
```ruby
class Schema < GraphQL::Schema
query QueryRoot
mutation MutationRoot
- use GraphQL::Execution::Interpreter # Required.
- use GraphQL::Analysis::AST # Required.
-
query_analyzer SimpleAnalyzer
instrument :query, GraphQL::Metrics::Instrumentation.new # Both of these are required if either is used.
tracer GraphQL::Metrics::Tracer.new # <-- Note!
@@ -201,13 +201,10 @@
```ruby
class Schema < GraphQL::Schema
query QueryRoot
mutation MutationRoot
- use GraphQL::Execution::Interpreter # Required.
- use GraphQL::Analysis::AST # Required.
-
query_analyzer SimpleAnalyzer
end
```
Your analyzer will still be called with `query_extracted`, `field_extracted`, but with timings metrics omitted.
@@ -222,17 +219,19 @@
Although you ideally will not need to care about these details if you are simply using this gem to gather metrics in
your application as intended, here's a breakdown of the order of execution of the methods involved:
When used as instrumentation, an analyzer and tracing, the order of execution is:
-* Tracer.setup_tracing
+* Tracer.capture_lexing_time
* Tracer.capture_parsing_time
+* Tracer.capture_multiplex_start_time
* Instrumentation.before_query (context setup)
* Tracer.capture_validation_time
* Tracer.capture_analysis_time
* Analyzer#initialize (bit more context setup, instance vars setup)
* Analyzer#result
+* Tracer.capture_query_start_time
* Tracer.trace_field (n times)
* Instrumentation.after_query (call query and field callbacks, now that we have all static and runtime metrics
gathered)
* Analyzer#extract_query
* Analyzer#query_extracted
@@ -252,10 +251,10 @@
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
-Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/graphql_metrics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
+Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/graphql-metrics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).