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 OpticsAgent::Reporting
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 ⇒ Object
Methods included from OpticsAgent::Reporting
#add_latency, #client_info, #duration_nanos, #generate_report_header, #generate_timestamp, #send_message
Methods included from Instrumentation
Constructor Details
#initialize(schema) ⇒ Schema
Returns a new instance of Schema.
18 19 20 21 22 23 24 |
# File 'lib/optics-agent/reporting/schema.rb', line 18 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.
16 17 18 |
# File 'lib/optics-agent/reporting/schema.rb', line 16 def @message end |
Instance Method Details
#get_types(schema) ⇒ Object
construct an array of Type (protobuf) objects
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/optics-agent/reporting/schema.rb', line 27 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.fields.values.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 ⇒ Object
52 53 54 |
# File 'lib/optics-agent/reporting/schema.rb', line 52 def send ('/api/ss/schema', @message) end |