graphql-hive 0.1.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 734441600a775933bd1250151b0234b7b8293d4ee49e087a86f80684fe116e74
4
- data.tar.gz: fe27f880db8cd0d75856fd8586363b6913f445feac2b7f7041a245eb03f49270
3
+ metadata.gz: a9f7e0924e498a6030eed43104a7fcf813d99ec671ecfc4b833ea58ca7670255
4
+ data.tar.gz: ffe20148dc4cec94758aec3633d4892ea88e5559ae253e23eb633c3f32d9c645
5
5
  SHA512:
6
- metadata.gz: 967bd101bad2140070d198d8b98ae92e4cb7a2716d4709c30b33862683ea35b7b3970c6c32f8727b57619698e7af43c039e79747d5f46a931ef345c2b44d54a7
7
- data.tar.gz: 9013380ae8c596b015571cc05cf0430658d984ee548c9fb21cc3d423d2a3b7459c298816dc765c053f33a49e41318916d665fd77aa4c5eae0a76fc5d7c81f1f6
6
+ metadata.gz: aebc0b8ec85f52e51fdf21328fad34c000d82fde6998832ee3581d2746167f41eca88a3e98d267f8dc02fa85cd34b3214028ece370f2446c7ca39c52b65e6fd3
7
+ data.tar.gz: 4fcc8132d44004f2fe19431c29782c1872975a8d1acd59218b41a95ab69ab72463ac7135ae64a5b14f1cfea660e432b63216dcaae3d8a4180401786bdf329fbc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-hive (0.1.4)
4
+ graphql-hive (0.2.0)
5
5
  graphql (~> 2.0.9)
6
6
 
7
7
  GEM
@@ -9,7 +9,7 @@ GEM
9
9
  specs:
10
10
  ast (2.4.2)
11
11
  diff-lcs (1.5.0)
12
- graphql (2.0.9)
12
+ graphql (2.0.15)
13
13
  parallel (1.22.1)
14
14
  parser (3.1.2.0)
15
15
  ast (~> 2.4.1)
@@ -41,7 +41,7 @@ end
41
41
  class Schema < GraphQL::Schema
42
42
  query QueryType
43
43
 
44
- use(GraphQL::Hive, { buffer_size: 2, token: 'c3715c1afab97070c5c5b9bce8d02c7b', debug: true, reporting: { author: 'Charly Poly', commit: '109bb1e748bae21bdfe663c0ffc7e830' }, client_info: proc { |context|
44
+ use(GraphQL::Hive, { buffer_size: 2, token: 'YOUR_TOKEN', debug: true, reporting: { author: 'Charly Poly', commit: '109bb1e748bae21bdfe663c0ffc7e830' }, client_info: proc { |context|
45
45
  { name: context[:client_name], version: context[:client_version] }
46
46
  } })
47
47
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Graphql
4
4
  module Hive
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
data/lib/graphql-hive.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
+ require 'securerandom'
4
5
 
5
6
  require 'graphql-hive/version'
6
7
  require 'graphql-hive/usage_reporter'
@@ -57,7 +58,8 @@ module GraphQL
57
58
  read_operations: true,
58
59
  report_schema: true,
59
60
  buffer_size: 50,
60
- logger: nil
61
+ logger: nil,
62
+ collect_usage_sampling: 1.0
61
63
  }.freeze
62
64
 
63
65
  self.platform_keys = {
@@ -114,7 +116,9 @@ module GraphQL
114
116
  elapsed = ending - starting
115
117
  duration = (elapsed.to_f * (10**9)).to_i
116
118
 
117
- report_usage(timestamp, queries, results, duration) unless queries.empty?
119
+ # rubocop:disable Layout/LineLength
120
+ report_usage(timestamp, queries, results, duration) if !queries.empty? && SecureRandom.random_number <= @options[:collect_usage_sampling]
121
+ # rubocop:enable Layout/LineLength
118
122
 
119
123
  results
120
124
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-hive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charly POLY
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
11
+ date: 2022-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql