Skip to content

Commit 9a1b613

Browse files
rozzajyemin
authored andcommitted
Added more driver name information
Previously, all drivers (legacy, sync, async) would just report the driver name "mongo-java-driver". This update appends extra information to the driver name: * legacy : mongo-java-driver|legacy * sync : mongo-java-driver|sync * async : mongo-java-driver|async * netty : mongo-java-driver|async|netty JAVA-3131
1 parent 3f47bb6 commit 9a1b613

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

driver-async/src/main/com/mongodb/async/client/MongoClients.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ static MongoClient createMongoClient(final MongoClientSettings settings, @Nullab
195195
private static Cluster createCluster(final MongoClientSettings settings, @Nullable final MongoDriverInformation mongoDriverInformation,
196196
final StreamFactory streamFactory, final StreamFactory heartbeatStreamFactory) {
197197
notNull("settings", settings);
198+
MongoDriverInformation.Builder builder = mongoDriverInformation == null ? MongoDriverInformation.builder()
199+
: MongoDriverInformation.builder(mongoDriverInformation);
198200
return new DefaultClusterFactory().createCluster(settings.getClusterSettings(), settings.getServerSettings(),
199201
settings.getConnectionPoolSettings(), streamFactory, heartbeatStreamFactory, settings.getCredentialList(),
200-
getCommandListener(settings.getCommandListeners()), settings.getApplicationName(), mongoDriverInformation,
202+
getCommandListener(settings.getCommandListeners()), settings.getApplicationName(), builder.driverName("async").build(),
201203
settings.getCompressorList());
202204
}
203205

driver-async/src/main/com/mongodb/async/client/NettyMongoClients.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ static MongoClient create(final MongoClientSettings settings, @Nullable final Mo
3434
StreamFactory streamFactory = new NettyStreamFactory(settings.getSocketSettings(), settings.getSslSettings(), eventLoopGroup);
3535
StreamFactory heartbeatStreamFactory = new NettyStreamFactory(settings.getHeartbeatSocketSettings(), settings.getSslSettings(),
3636
eventLoopGroup);
37-
return MongoClients.createMongoClient(settings, mongoDriverInformation, streamFactory, heartbeatStreamFactory,
37+
MongoDriverInformation.Builder builder = mongoDriverInformation == null ? MongoDriverInformation.builder()
38+
: MongoDriverInformation.builder(mongoDriverInformation);
39+
return MongoClients.createMongoClient(settings, builder.driverName("netty").build(), streamFactory, heartbeatStreamFactory,
3840
new Closeable() {
3941
@Override
4042
public void close() {

driver-legacy/src/main/com/mongodb/Mongo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ private static Cluster createCluster(final ServerAddress serverAddress, final Li
746746

747747
private static Cluster createCluster(final ClusterSettings clusterSettings, final List<MongoCredential> credentialsList,
748748
final MongoClientOptions options, @Nullable final MongoDriverInformation mongoDriverInformation) {
749+
MongoDriverInformation.Builder builder = mongoDriverInformation == null ? MongoDriverInformation.builder()
750+
: MongoDriverInformation.builder(mongoDriverInformation);
749751
return new DefaultClusterFactory().createCluster(clusterSettings,
750752
options.getServerSettings(),
751753
options.getConnectionPoolSettings(),
@@ -758,7 +760,7 @@ private static Cluster createCluster(final ClusterSettings clusterSettings, fina
758760
credentialsList,
759761
getCommandListener(options.getCommandListeners()),
760762
options.getApplicationName(),
761-
mongoDriverInformation,
763+
builder.driverName("legacy").build(),
762764
options.getCompressorList());
763765
}
764766

driver-sync/src/main/com/mongodb/client/MongoClients.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public static MongoClient create(final ConnectionString connectionString,
109109
* @return the client
110110
*/
111111
public static MongoClient create(final MongoClientSettings settings, @Nullable final MongoDriverInformation mongoDriverInformation) {
112-
return new MongoClientImpl(settings, mongoDriverInformation);
112+
MongoDriverInformation.Builder builder = mongoDriverInformation == null ? MongoDriverInformation.builder()
113+
: MongoDriverInformation.builder(mongoDriverInformation);
114+
return new MongoClientImpl(settings, builder.driverName("sync").build());
113115
}
114116

115117
private MongoClients() {

0 commit comments

Comments
 (0)