Class: OpticsAgent::Reporting::Schema
- Inherits:
-
Object
- Object
- OpticsAgent::Reporting::Schema
- Defined in:
- lib/optics-agent/reporting/schema.rb
Overview
A report for a whole schema
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
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
-
#get_types(schema) ⇒ Object
construct an array of Type (protobuf) objects.
-
#initialize(schema) ⇒ Schema
constructor
A new instance of Schema.
- #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
Methods included from Instrumentation
Constructor Details
#initialize(schema) ⇒ Schema
Returns a new instance of Schema.
17 18 19 20 21 22 23 |
# File 'lib/optics-agent/reporting/schema.rb', line 17 def initialize(schema) @message = SchemaReport.new({ header: generate_report_header(), introspection_result: JSON.generate(introspect_schema(schema)), type: get_types(schema) }) end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
15 16 17 |
# File 'lib/optics-agent/reporting/schema.rb', line 15 def @message end |
Instance Method Details
#get_types(schema) ⇒ Object
construct an array of Type (protobuf) objects
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/schema.rb', line 26 def get_types(schema) types = [] schema.types.keys.each do |type_name| next if type_name =~ /^__/ type = schema.types[type_name] next unless type.is_a? GraphQL::ObjectType fields = type.all_fields.map do |field| Field.new({ name: field.name, # XXX: does this actually work for all types? returnType: field.type.to_s }) end types << Type.new({ name: type_name, field: fields }) end types end |
#send_with(agent) ⇒ Object
51 52 53 |
# File 'lib/optics-agent/reporting/schema.rb', line 51 def send_with(agent) agent.('/api/ss/schema', @message) end |