optics-agent 0.4.0 → 0.4.1
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 +4 -4
- data/README.md +9 -4
- data/lib/optics-agent.rb +2 -0
- data/lib/optics-agent/agent.rb +10 -3
- data/lib/optics-agent/instrumenters/field.rb +2 -1
- data/lib/optics-agent/rack-middleware.rb +1 -1
- data/lib/optics-agent/railtie.rb +7 -0
- data/lib/optics-agent/reporting/query.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b2a148777b845f0cf7b9857985e17546a70320
|
4
|
+
data.tar.gz: 48aab1abbf6eb781bf9a1744e0ffec7ac551c85a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2179a4eb6d2d6be7cdd61be3aa84a66e82afcba9687023a4106cc4671533bc4c158c7c0c6af6a3449755611ed174b20c22db078a7ec99fb273c2398829369cb2
|
7
|
+
data.tar.gz: 98079604f11e6cf92e5ebdcbabbffa389fac48ded7f0560444f6866f0d674775a95111b794d5884a53f22df841778fb7f391ed9510a29b8df221356c1f21883d
|
data/README.md
CHANGED
@@ -69,7 +69,8 @@ agent.configure do
|
|
69
69
|
# The schema you wish to instrument
|
70
70
|
schema YourSchema
|
71
71
|
|
72
|
-
# Your API key for the Optics service. This defaults to the OPTICS_API_KEY
|
72
|
+
# Your API key for the Optics service. This defaults to the OPTICS_API_KEY
|
73
|
+
# environment variable, but can be overridden here.
|
73
74
|
api_key ENV['OPTICS_API_KEY']
|
74
75
|
|
75
76
|
# Log detailed debugging messages
|
@@ -84,13 +85,17 @@ agent.configure do
|
|
84
85
|
# Send detailed traces along with usage reports
|
85
86
|
report_traces true
|
86
87
|
|
87
|
-
# How long to wait before sending a schema report after startup, in
|
88
|
+
# How long to wait before sending a schema report after startup, in
|
89
|
+
# milliseconds
|
88
90
|
schema_report_delay_ms 10 * 1000
|
89
91
|
|
90
|
-
# How often to send reports in milliseconds. Defaults to 1 minute.
|
92
|
+
# How often to send reports in milliseconds. Defaults to 1 minute.
|
93
|
+
# You shouldn't need to set this unless you are debugging.
|
91
94
|
report_interval_ms 60 * 1000
|
92
95
|
|
93
|
-
# Where to send the reports. Defaults to the production Optics endpoint,
|
96
|
+
# Where to send the reports. Defaults to the production Optics endpoint,
|
97
|
+
# or the `OPTICS_ENDPOINT_URL` environment variable if it is set.
|
98
|
+
# You shouldn't need to set this unless you are debugging
|
94
99
|
endpoint_url 'https://optics-report.apollodata.com'
|
95
100
|
end
|
96
101
|
```
|
data/lib/optics-agent.rb
CHANGED
data/lib/optics-agent/agent.rb
CHANGED
@@ -10,6 +10,12 @@ module OpticsAgent
|
|
10
10
|
class Agent
|
11
11
|
include OpticsAgent::Reporting
|
12
12
|
|
13
|
+
class << self
|
14
|
+
attr_accessor :logger
|
15
|
+
end
|
16
|
+
|
17
|
+
self.logger = Logger.new(STDOUT)
|
18
|
+
|
13
19
|
attr_reader :schema, :report_traces
|
14
20
|
|
15
21
|
def initialize
|
@@ -150,17 +156,18 @@ Use the `schema` configuration setting, or call `agent.instrument_schema`
|
|
150
156
|
|
151
157
|
def log(message = nil)
|
152
158
|
message = yield unless message
|
153
|
-
|
159
|
+
self.class.logger.info "optics-agent: #{message}"
|
154
160
|
end
|
155
161
|
|
156
162
|
def warn(message = nil)
|
157
|
-
|
163
|
+
self.class.logger.warn "optics-agent: WARNING: #{message}"
|
158
164
|
end
|
159
165
|
|
166
|
+
# Should we be using built in debug levels rather than our own "debug" flag?
|
160
167
|
def debug(message = nil)
|
161
168
|
if @configuration.debug
|
162
169
|
message = yield unless message
|
163
|
-
|
170
|
+
self.class.logger.info "optics-agent: DEBUG: #{message} <#{Process.pid} | #{Thread.current.object_id}>"
|
164
171
|
end
|
165
172
|
end
|
166
173
|
end
|
@@ -27,7 +27,8 @@ module OpticsAgent
|
|
27
27
|
when executing your graphql query.
|
28
28
|
If you don't want to instrument this query, pass `context: {optics_agent: :skip}`.
|
29
29
|
"""
|
30
|
-
|
30
|
+
# don't warn again for this query
|
31
|
+
agent_context = query_context[:optics_agent] = :skip
|
31
32
|
end
|
32
33
|
|
33
34
|
# This happens when an introspection query occurs (reporting schema)
|
@@ -29,7 +29,7 @@ module OpticsAgent
|
|
29
29
|
|
30
30
|
agent.debug { "rack-middleware: request finished" }
|
31
31
|
if (query.document)
|
32
|
-
agent.debug { "rack-middleware:
|
32
|
+
agent.debug { "rack-middleware: Adding a query with #{query.reports.length} field reports" }
|
33
33
|
query.finish!
|
34
34
|
agent.add_query(query, env)
|
35
35
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'Tom Coleman '
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/optics-agent/normalization/latency.rb
|
127
127
|
- lib/optics-agent/normalization/query.rb
|
128
128
|
- lib/optics-agent/rack-middleware.rb
|
129
|
+
- lib/optics-agent/railtie.rb
|
129
130
|
- lib/optics-agent/reporting/helpers.rb
|
130
131
|
- lib/optics-agent/reporting/query-trace.rb
|
131
132
|
- lib/optics-agent/reporting/query.rb
|