optics-agent 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +3 -3
- data/lib/optics-agent/agent.rb +5 -1
- data/lib/optics-agent/normalization/latency.rb +1 -1
- data/lib/optics-agent/reporting/report_job.rb +1 -1
- data/spec/latency_spec.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjIwMWU1NjYxNGYzNzhhMzk1Y2IwODMxZTE1NjZkYjUwNTY1NTQ5YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTNkMjcxMjAyNWJlY2E1OTc4NTVkY2NmMTZjMGZiODdkNDg4ZTFkMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTRkYTZlZDlhMDNmMjQ5OGU5MTliNDVkNWRhYzUzMjIzMDMwNTNjYjQ4NTg2
|
10
|
+
OTNkOWRmOWM1YmE2YWViNzE2MGExZDliNzQwZjcxZjFkYmNmNjA2MGM5OWMz
|
11
|
+
ZjhmOGFmODM2MWFjMDM5Njc3OTU2YzFmMDgyN2FiYmUwMmVmYWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWM4ZDQwOGU5MTZjYTVhY2MwZjg4NWQ4MjA5Zjc2OGZjZWUyZTlkMTc2YTI1
|
14
|
+
MTk4YzQzZWEyNGY1YmUwMDUzZTg2Mjg3NTk4MTIyNGNiMjA4ZGNhNjQwYWE1
|
15
|
+
ZGE0ZjEyMTdiNmJlZTM3NDFlN2E3YTEyOTNhZmUyZTJkYzQ4NTM=
|
data/README.md
CHANGED
@@ -59,12 +59,12 @@ end
|
|
59
59
|
|
60
60
|
## Rails
|
61
61
|
|
62
|
-
The equivalent of the above for Rails is
|
62
|
+
The equivalent of the above for Rails is:
|
63
63
|
|
64
64
|
Create an agent in `config/apllication.rb`, and register the rack middleware:
|
65
65
|
|
66
66
|
```ruby
|
67
|
-
module
|
67
|
+
module YourApplicationRails
|
68
68
|
class Application < Rails::Application
|
69
69
|
# ...
|
70
70
|
|
@@ -81,7 +81,7 @@ Register the Graphql middleware when you create your schema:
|
|
81
81
|
Rails.application.config.optics_agent.instrument_schema(YourSchema)
|
82
82
|
```
|
83
83
|
|
84
|
-
|
84
|
+
Register Optics Agent on the GraphQL context within your `graphql` action as below:
|
85
85
|
|
86
86
|
```ruby
|
87
87
|
def create
|
data/lib/optics-agent/agent.rb
CHANGED
@@ -19,7 +19,6 @@ module OpticsAgent
|
|
19
19
|
def initialize
|
20
20
|
@query_queue = []
|
21
21
|
@semaphone = Mutex.new
|
22
|
-
ReportJob.perform_in(60, self)
|
23
22
|
end
|
24
23
|
|
25
24
|
def instrument_schema(schema)
|
@@ -28,6 +27,11 @@ module OpticsAgent
|
|
28
27
|
|
29
28
|
puts 'scheduling schema job'
|
30
29
|
SchemaJob.perform_in(10, self)
|
30
|
+
schedule_report
|
31
|
+
end
|
32
|
+
|
33
|
+
def schedule_report
|
34
|
+
ReportJob.perform_in(60, self)
|
31
35
|
end
|
32
36
|
|
33
37
|
def add_query(query, rack_env, start_time, end_time)
|
@@ -6,7 +6,7 @@ module OpticsAgent
|
|
6
6
|
|
7
7
|
# see https://github.com/apollostack/optics-agent/blob/master/docs/histograms.md
|
8
8
|
def latency_bucket(micros)
|
9
|
-
bucket = Math.log(micros) / Math.log(1.1)
|
9
|
+
bucket = Math.log([0, micros].max) / Math.log(1.1)
|
10
10
|
|
11
11
|
[255, [0, bucket].max].min.ceil.to_i
|
12
12
|
end
|
data/spec/latency_spec.rb
CHANGED
@@ -14,15 +14,30 @@ describe 'latency helpers' do
|
|
14
14
|
describe 'latency_bucket' do
|
15
15
|
it 'returns the right values' do
|
16
16
|
tests = [
|
17
|
+
[-1, 0],
|
18
|
+
[0, 0],
|
19
|
+
# 1 nanosecond
|
20
|
+
[0.001, 0],
|
17
21
|
[0.1, 0],
|
18
22
|
[0.9, 0],
|
23
|
+
[0.999, 0],
|
24
|
+
# 1 microsecond
|
19
25
|
[1, 0],
|
26
|
+
[1.001, 1],
|
20
27
|
[1.1, 1],
|
28
|
+
[1.101, 2],
|
21
29
|
[1.21, 2],
|
30
|
+
[10, 25],
|
31
|
+
[10.834, 25],
|
32
|
+
[10.835, 26],
|
22
33
|
[100, 49],
|
34
|
+
# 1 millisecond
|
23
35
|
[1000, 73],
|
36
|
+
# 1 second
|
24
37
|
[1000 * 1000, 145],
|
25
38
|
[1.1**254, 255],
|
39
|
+
# 5 days
|
40
|
+
[5 * 24 * 60 * 60 * 1000 * 1000, 255],
|
26
41
|
[1000 * 1000 * 1000 * 1000, 255]
|
27
42
|
]
|
28
43
|
|