lib/fluent/plugin/in_protobuf_http.rb in fluent-plugin-protobuf-http-0.3.0 vs lib/fluent/plugin/in_protobuf_http.rb in fluent-plugin-protobuf-http-0.3.1
- old
+ new
@@ -114,12 +114,13 @@
def get_msg_types(compiled_proto)
log.debug("Extracting message types [#{compiled_proto}]...")
msg_types = []
File.foreach(compiled_proto) do |line|
- if line.lstrip.start_with?('add_message')
- msg_type = line[/"([^"]*)"/, 1] # regex: <add_message> 'msg_type' <do>
- msg_types.push(msg_type) unless msg_type.nil?
+ line.strip!
+ if line.include?('::Google::Protobuf::DescriptorPool.generated_pool.lookup') && line.end_with?('.msgclass')
+ extracted_msg_type = line[/"([^"]*)"/, 1].freeze
+ msg_types.push(extracted_msg_type) unless extracted_msg_type.nil?
end
end
if msg_types.any?
log.info("Total [#{msg_types.length}] message types in [#{compiled_proto}]:\n- #{msg_types.join("\n- ")}")