Skip to content

Commit

Permalink
Send client and java version to server (#59)
Browse files Browse the repository at this point in the history
* Send client and java version to server
  • Loading branch information
tellet-q authored Dec 10, 2024
1 parent d71b260 commit 593a397
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build/
.idea/uiDesigner.xml
.idea/codeStyles/codeStyleConfig.xml
.idea/codeStyles/Project.xml
.idea/inspectionProfiles/Project_Default.xml
*.iws
*.iml
*.ipr
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jar {
// add git revision and commit time to jar manifest
jar.manifest.attributes['X-Git-Revision'] = git.head().id
jar.manifest.attributes['X-Git-Commit-Time'] = git.head().dateTime.withZoneSameLocal(ZoneOffset.UTC)
jar.manifest.attributes['Implementation-Version'] = packageVersion
git.close()
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/io/qdrant/client/QdrantGrpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ public static class Builder {
}

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

Expand Down Expand Up @@ -222,7 +225,7 @@ public QdrantGrpcClient build() {
}

private static ManagedChannel createChannel(
String host, int port, boolean useTransportLayerSecurity) {
String host, int port, boolean useTransportLayerSecurity, String userAgent) {
ManagedChannelBuilder<?> channelBuilder = ManagedChannelBuilder.forAddress(host, port);

if (useTransportLayerSecurity) {
Expand All @@ -231,6 +234,8 @@ private static ManagedChannel createChannel(
channelBuilder.usePlaintext();
}

channelBuilder.userAgent(userAgent);

return channelBuilder.build();
}
}
Expand Down

0 comments on commit 593a397

Please sign in to comment.