def start_segment
product, operation, collection = ActiveRecordHelper.product_operation_collection_for(payload[:name],
sql, @config && @config[:adapter])
host = nil
port_path_or_id = nil
database = nil
if ActiveRecordHelper::InstanceIdentification.supported_adapter?(@config)
host = ActiveRecordHelper::InstanceIdentification.host(@config)
port_path_or_id = ActiveRecordHelper::InstanceIdentification.port_path_or_id(@config)
database = @config && @config[:database]
end
segment = NewRelic::Agent::Transaction::DatastoreSegment.new product, operation, collection, host, port_path_or_id, database
if txn = state.current_transaction
segment.transaction = txn
end
segment._notice_sql sql, @config, @explainer, payload[:binds], payload[:name]
segment.start
segment
end