Class: OpticsAgent::Reporting::QueryTrace
- Inherits:
-
Object
- Object
- OpticsAgent::Reporting::QueryTrace
- Includes:
- Apollo::Optics::Proto, OpticsAgent::Reporting
- Defined in:
- lib/optics-agent/reporting/query-trace.rb
Overview
A trace is just a different view of a single query report, with full information about start and end times
Constant Summary
Constants included from Apollo::Optics::Proto
Apollo::Optics::Proto::Error, Apollo::Optics::Proto::Field, Apollo::Optics::Proto::FieldStat, Apollo::Optics::Proto::Id128, Apollo::Optics::Proto::ReportHeader, Apollo::Optics::Proto::SchemaReport, Apollo::Optics::Proto::StatsPerClientName, Apollo::Optics::Proto::StatsPerSignature, Apollo::Optics::Proto::StatsReport, Apollo::Optics::Proto::Timestamp, Apollo::Optics::Proto::Trace, Apollo::Optics::Proto::TracesReport, Apollo::Optics::Proto::Type, Apollo::Optics::Proto::TypeStat
Instance Attribute Summary collapse
-
#report ⇒ Object
Returns the value of attribute report.
Instance Method Summary collapse
-
#initialize(query, rack_env) ⇒ QueryTrace
constructor
A new instance of QueryTrace.
- #send_with(agent) ⇒ Object
Methods included from OpticsAgent::Reporting
#add_latency, #client_info, #duration_micros, #duration_nanos, #generate_report_header, #generate_timestamp, #latency_bucket_for_duration
Constructor Details
#initialize(query, rack_env) ⇒ QueryTrace
Returns a new instance of QueryTrace.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/optics-agent/reporting/query-trace.rb', line 13 def initialize(query, rack_env) trace = Trace.new({ start_time: (query.start_time), end_time: (query.end_time), duration_ns: duration_nanos(query.duration), signature: query.signature }) # XXX: report trace details (not totally clear yet from the JS agent what should be here) trace.details = Trace::Details.new({}) info = client_info(rack_env) trace.client_name = info[:client_name] trace.client_version = info[:client_version] trace.client_address = info[:client_address] trace.http = Trace::HTTPInfo.new({ host: "localhost:8080", path: "/graphql" }) nodes = [] query.each_report do |type_name, field_name, start_offset, duration| nodes << Trace::Node.new({ field_name: "#{type_name}.#{field_name}", start_time: duration_nanos(start_offset), end_time: duration_nanos(start_offset + duration) }) end trace.execute = Trace::Node.new({ child: nodes }) @report = TracesReport.new({ header: generate_report_header, trace: [trace] }) end |
Instance Attribute Details
#report ⇒ Object
Returns the value of attribute report.
11 12 13 |
# File 'lib/optics-agent/reporting/query-trace.rb', line 11 def report @report end |
Instance Method Details
#send_with(agent) ⇒ Object
51 52 53 |
# File 'lib/optics-agent/reporting/query-trace.rb', line 51 def send_with(agent) agent.('/api/ss/traces', @report) end |