Module: OpticsAgent::Reporting
- Included in:
- Agent, Query, QueryTrace, Report, Schema
- Defined in:
- lib/optics-agent/reporting/query.rb,
lib/optics-agent/reporting/report.rb,
lib/optics-agent/reporting/schema.rb,
lib/optics-agent/reporting/helpers.rb,
lib/optics-agent/reporting/report_job.rb,
lib/optics-agent/reporting/schema_job.rb,
lib/optics-agent/reporting/query-trace.rb,
lib/optics-agent/reporting/send-message.rb
Defined Under Namespace
Classes: Query, QueryTrace, Report, ReportJob, Schema, SchemaJob
Constant Summary
collapse
- OPTICS_URL =
'https://optics-report.apollodata.com'
Instance Method Summary
collapse
Instance Method Details
#add_latency(counts, start_time, end_time) ⇒ Object
32
33
34
35
36
|
# File 'lib/optics-agent/reporting/helpers.rb', line 32
def add_latency(counts, start_time, end_time)
micros = (end_time - start_time) * 1e6
bucket = latency_bucket(micros)
counts[bucket] += 1
end
|
#client_info(rack_env) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/optics-agent/reporting/helpers.rb', line 24
def client_info(rack_env)
{
client_name: 'none',
client_version: 'none',
client_address: '::1'
}
end
|
#duration_nanos(start_time, end_time) ⇒ Object
18
19
20
21
|
# File 'lib/optics-agent/reporting/helpers.rb', line 18
def duration_nanos(start_time, end_time)
throw "start_time before end_time" if (start_time > end_time)
((end_time - start_time) * 1e9).to_i
end
|
#generate_timestamp(time) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/optics-agent/reporting/helpers.rb', line 11
def generate_timestamp(time)
Apollo::Optics::Proto::Timestamp.new({
seconds: time.to_i,
nanos: time.to_i % 1 * 1e9
});
end
|
#send_message(path, message) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/optics-agent/reporting/send-message.rb', line 6
def send_message(path, message)
req = Net::HTTP::Post.new(path)
req['x-api-key'] = ENV['OPTICS_API_KEY']
req['user-agent'] = "optics-agent-rb"
req.body = message.class.encode(message)
puts message.class.encode_json(message)
uri = URI.parse(OPTICS_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
res = http.request(req)
p res
p res.body
end
|