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 +4 -4
- data/lib/optics-agent/agent.rb +7 -0
- data/lib/optics-agent/rack-middleware.rb +1 -0
- data/spec/benchmark/benchmark.rb +19 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baf3d71a589fb44d4c5334e9536b40bf102776be
|
4
|
+
data.tar.gz: 5d2c8f79f113afb70a170d4464b577b83db45c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55989f7e56a1f233ca326e848e3869666714a2b0a892adb11c96d985e5331159fa69b23a27aa58332bf2ae155697a6f1b45bf613aad8a7511aa5fd0dcf594d0
|
7
|
+
data.tar.gz: 877b3599a864ddb80e66df0f2c9b95578ececf581dc87136fb8db819f90beb4a4e2b2ea6b9a2c36272f18c7159006c8bf7db2e3bbd6dc67d9c51f87c2512bacc
|
data/lib/optics-agent/agent.rb
CHANGED
@@ -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
|
|
data/spec/benchmark/benchmark.rb
CHANGED
@@ -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
|
-
|
15
|
-
|
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.
|
32
|
+
Benchmark.bmbm(4) do |x|
|
20
33
|
x.report("No agent") do
|
21
|
-
|
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
|
-
|
39
|
+
1000.times do
|
27
40
|
instrumented_schema.execute(query_string, context: {
|
28
|
-
optics_agent:
|
41
|
+
optics_agent: rack_agent
|
29
42
|
})
|
30
43
|
end
|
31
44
|
end
|