Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3873

MongoClient - how to get the list of the servers?

    • Type: Icon: Improvement Improvement
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.5
    • Component/s: API, Monitoring
    • None

      I am trying to upgrade some opentracing libraries to use the drivers 4.0.x, in particular this project (https://github.com/opentracing-contrib/java-mongo-driver and this project (https://github.com/opentracing-contrib/java-spring-cloud).

      They stopped working because they are based on this code:

      if (bean instanceof MongoClient && !(bean instanceof TracingMongoClient)) {
        final MongoClient client = (MongoClient) bean;
      
        final TracingCommandListener commandListener = new TracingCommandListener.Builder(tracer).build();
      
        return new TracingMongoClient(commandListener, client.getServerAddressList(), 
                                                               client.getCredential(), 
                                                               client.getMongoClientOptions());
       }
      

       
      But in the version 4.0.5 the method `client.getServerAddressList()` is not available anymore.

      If I have the client, how am I supposed now to retrieve the list of the addresses?

      The final goal is being able to have a (new?) MongoClient with a command listener, starting from a "naked" MongoClient. Is there any other way of doing that?

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            e.massara@faceit.com Emanuele Massara
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: