# RequestTracker

<div class="jsdoc-content"><header>
    
        <h2>
            <span class="ancestors"><a href="index.html">tracker</a>~</span>RequestTracker</h2>
        
            <div class="class-description"><p>Tracks request execution for a <a href="../Client.html">Client</a>.</p>
<p>A RequestTracker can be configured in the client options. The <code>Client</code> will execute
RequestTracker#onSuccess or RequestTracker#onError for every query or batch
executed (QUERY, EXECUTE and BATCH requests).</p></div>
        
    
</header>


    
        

        


<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/tracker/request-tracker.js#L13" target="_blank" rel="noopener">tracker/request-tracker.js, line 13</a></p></div>


        
    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="onError"><span class="type-signature"></span>onError<span class="signature">(host, query, parameters, executionOptions, requestLength, err, latency)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Invoked each time a query or batch request fails.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>host</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="Host.html">Host</a></span>


            
            </td>

            

            

            <td class="description last"><p>The node that acted as coordinator of the request.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array&lt;any></span>


            
            </td>

            

            

            <td class="description last"><p>In the case of prepared or unprepared query executions, the provided
query string. For batch requests, an Array containing the queries and parameters provided.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>parameters</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>
|

<span class="param-type">null</span>


            
            </td>

            

            

            <td class="description last"><p>In the case of prepared or unprepared query executions, the provided
parameters.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>executionOptions</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="../ExecutionOptions.html">ExecutionOptions</a></span>


            
            </td>

            

            

            <td class="description last"><p>The information related to the execution of the request.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>requestLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last"><p>Length of the body of the request. When the failure occurred before the request was
written to the wire, the length will be <code>0</code>.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>err</code></td>
            

            <td class="type">
            
                
<span class="param-type">Error</span>


            
            </td>

            

            

            <td class="description last"><p>The error that caused that caused the request to fail.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>latency</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;Number></span>


            
            </td>

            

            

            <td class="description last"><p>An array containing [seconds, nanoseconds] tuple, where nanoseconds is the
remaining part of the real time that can't be represented in second precision (see <code>process.hrtime()</code>).</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/tracker/request-tracker.js#L51" target="_blank" rel="noopener">tracker/request-tracker.js, line 51</a></p></div>




















        
            

    

    
    <h4 class="name" id="onSuccess"><span class="type-signature"></span>onSuccess<span class="signature">(host, query, parameters, executionOptions, requestLength, responseLength, latency)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Invoked each time a query or batch request succeeds.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>host</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="Host.html">Host</a></span>


            
            </td>

            

            

            <td class="description last"><p>The node that acted as coordinator of the request.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>
|

<span class="param-type">Array&lt;any></span>


            
            </td>

            

            

            <td class="description last"><p>In the case of prepared or unprepared query executions, the provided
query string. For batch requests, an Array containing the queries and parameters provided.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>parameters</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;any></span>
|

<span class="param-type">Object</span>
|

<span class="param-type">null</span>


            
            </td>

            

            

            <td class="description last"><p>In the case of prepared or unprepared query executions, the provided
parameters.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>executionOptions</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="../ExecutionOptions.html">ExecutionOptions</a></span>


            
            </td>

            

            

            <td class="description last"><p>The information related to the execution of the request.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>requestLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last"><p>Length of the body of the request.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>responseLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last"><p>Length of the body of the response.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>latency</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array&lt;Number></span>


            
            </td>

            

            

            <td class="description last"><p>An array containing [seconds, nanoseconds] tuple, where nanoseconds is the
remaining part of the real time that can't be represented in second precision (see <code>process.hrtime()</code>).</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/tracker/request-tracker.js#L27" target="_blank" rel="noopener">tracker/request-tracker.js, line 27</a></p></div>




















        
            

    

    
    <h4 class="name" id="shutdown"><span class="type-signature"></span>shutdown<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Invoked when the Client is being shutdown.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/tracker/request-tracker.js#L64" target="_blank" rel="noopener">tracker/request-tracker.js, line 64</a></p></div></div>
