Skip to content

Commit 593a397

Browse files
authored
Send client and java version to server (#59)
* Send client and java version to server
1 parent d71b260 commit 593a397

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build/
1212
.idea/uiDesigner.xml
1313
.idea/codeStyles/codeStyleConfig.xml
1414
.idea/codeStyles/Project.xml
15+
.idea/inspectionProfiles/Project_Default.xml
1516
*.iws
1617
*.iml
1718
*.ipr

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jar {
7474
// add git revision and commit time to jar manifest
7575
jar.manifest.attributes['X-Git-Revision'] = git.head().id
7676
jar.manifest.attributes['X-Git-Commit-Time'] = git.head().dateTime.withZoneSameLocal(ZoneOffset.UTC)
77+
jar.manifest.attributes['Implementation-Version'] = packageVersion
7778
git.close()
7879
}
7980
}

src/main/java/io/qdrant/client/QdrantGrpcClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ public static class Builder {
174174
}
175175

176176
Builder(String host, int port, boolean useTransportLayerSecurity) {
177-
this.channel = createChannel(host, port, useTransportLayerSecurity);
177+
String clientVersion = Builder.class.getPackage().getImplementationVersion();
178+
String javaVersion = System.getProperty("java.version");
179+
String userAgent = "java-client/" + clientVersion + " java/" + javaVersion;
180+
this.channel = createChannel(host, port, useTransportLayerSecurity, userAgent);
178181
this.shutdownChannelOnClose = true;
179182
}
180183

@@ -222,7 +225,7 @@ public QdrantGrpcClient build() {
222225
}
223226

224227
private static ManagedChannel createChannel(
225-
String host, int port, boolean useTransportLayerSecurity) {
228+
String host, int port, boolean useTransportLayerSecurity, String userAgent) {
226229
ManagedChannelBuilder<?> channelBuilder = ManagedChannelBuilder.forAddress(host, port);
227230

228231
if (useTransportLayerSecurity) {
@@ -231,6 +234,8 @@ private static ManagedChannel createChannel(
231234
channelBuilder.usePlaintext();
232235
}
233236

237+
channelBuilder.userAgent(userAgent);
238+
234239
return channelBuilder.build();
235240
}
236241
}

0 commit comments

Comments
 (0)