optics-agent 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 75440b51ee6807fa478559568ca0fc7934e38c5f
4
- data.tar.gz: 6c7302b7b48ff60c89f92602663b680502318af0
3
+ metadata.gz: baf3d71a589fb44d4c5334e9536b40bf102776be
4
+ data.tar.gz: 5d2c8f79f113afb70a170d4464b577b83db45c9a
5
5
  SHA512:
6
- metadata.gz: d201e91158930766f7efd34210b9af68d4575c658672209363dc8614746577256a66da8e854f5b314b376988f72f65070aa9e898e93dc0e58b4485858d4ba728
7
- data.tar.gz: 2593d4184b7766bd232f0d950a004ab70b8556af248c2bda482c1eb7e268b20b9f307c0bcc07dd61192b43821df57d492df24e6258e3d0bbf79f299769940696
6
+ metadata.gz: c55989f7e56a1f233ca326e848e3869666714a2b0a892adb11c96d985e5331159fa69b23a27aa58332bf2ae155697a6f1b45bf613aad8a7511aa5fd0dcf594d0
7
+ data.tar.gz: 877b3599a864ddb80e66df0f2c9b95578ececf581dc87136fb8db819f90beb4a4e2b2ea6b9a2c36272f18c7159006c8bf7db2e3bbd6dc67d9c51f87c2512bacc
@@ -56,8 +56,15 @@ module OpticsAgent
56
56
  debug "running schema job"
57
57
  SchemaJob.new.perform(self)
58
58
  end
59
+ end
60
+ end
59
61
 
62
+ # we call this method on every request to ensure that the reporting thread
63
+ # is active in the correct process for pre-forking webservers like unicorn
64
+ def ensure_reporting!
65
+ unless @reporting_thread_active
60
66
  schedule_report
67
+ @reporting_thread_active = true
61
68
  end
62
69
  end
63
70
 
@@ -12,6 +12,7 @@ module OpticsAgent
12
12
 
13
13
  # XXX: figure out a way to pass this in here
14
14
  agent = OpticsAgent::Agent.instance
15
+ agent.ensure_reporting!
15
16
  agent.debug { "rack-middleware: request started" }
16
17
  query = OpticsAgent::Reporting::Query.new
17
18
 
@@ -1,3 +1,5 @@
1
+ # Run with ruby -Ilib spec/benchmark/benchmark.rb
2
+
1
3
  require 'benchmark'
2
4
  require 'graphql'
3
5
  require 'optics-agent'
@@ -7,25 +9,36 @@ require_relative '../support/create_starwars_schema.rb';
7
9
  basic_schema = create_starwars_schema
8
10
 
9
11
  agent = OpticsAgent::Agent.instance
12
+ agent.set_options(disable_reporting: true)
10
13
  instrumented_schema = create_starwars_schema
11
14
  agent.instrument_schema(instrumented_schema)
12
15
 
13
16
  # just drop reports on the floor
14
- null_reporter = {}
15
- null_reporter.define_singleton_method :report_field, lambda { |x,y,z,w| }
17
+ class BenchmarkRackAgent
18
+ class Query
19
+ def report_field(x,y,z,w)
20
+ end
21
+ end
22
+
23
+ attr_reader :query
24
+ def initialize
25
+ @query = Query.new
26
+ end
27
+ end
28
+ rack_agent = BenchmarkRackAgent.new
16
29
 
17
30
  query_string = GraphQL::Introspection::INTROSPECTION_QUERY
18
31
 
19
- Benchmark.bm(7) do |x|
32
+ Benchmark.bmbm(4) do |x|
20
33
  x.report("No agent") do
21
- 20.times do
34
+ 1000.times do
22
35
  basic_schema.execute(query_string)
23
36
  end
24
37
  end
25
38
  x.report("With agent") do
26
- 20.times do
39
+ 1000.times do
27
40
  instrumented_schema.execute(query_string, context: {
28
- optics_agent: { query: null_reporter }
41
+ optics_agent: rack_agent
29
42
  })
30
43
  end
31
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optics-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Tom Coleman '