title: Which Mongo instance in Replica Set did the application call?
body: <p>I have a Java application, which works with a Mongo <em>replica set</em>. The replica set consists of two Mongo instances (primary and secondary) in different hosts</p>
  
  <p>Suppose the application is executing a query (e.g. find a document in a collection). I don't know what <a href="http://docs.mongodb.org/manual/core/read-preference/" rel="nofollow">read preference</a> it uses. Suppose also that both <em>primary</em> and <em>secondary</em> instances store the same data. </p>
  
  <p>Now I need to know <em>which</em> Mongo instance the application has called to execute the query: the <em>primary</em>, the <em>secondary</em>, or the both.</p>
  
  <p>How can I do that ?</p>
  
  <p>I would prefer a solution, which does not require access to the application code.</p>