From 593a39788bfe2b9183902eec0e06529a2243b341 Mon Sep 17 00:00:00 2001 From: tellet-q <166374656+tellet-q@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:16:43 +0100 Subject: [PATCH] Send client and java version to server (#59) * Send client and java version to server --- .gitignore | 1 + build.gradle | 1 + src/main/java/io/qdrant/client/QdrantGrpcClient.java | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 761f16b..c6509f6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ build/ .idea/uiDesigner.xml .idea/codeStyles/codeStyleConfig.xml .idea/codeStyles/Project.xml +.idea/inspectionProfiles/Project_Default.xml *.iws *.iml *.ipr diff --git a/build.gradle b/build.gradle index c7e5fab..46ba1f7 100644 --- a/build.gradle +++ b/build.gradle @@ -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() } } diff --git a/src/main/java/io/qdrant/client/QdrantGrpcClient.java b/src/main/java/io/qdrant/client/QdrantGrpcClient.java index bc24a29..17c3aef 100644 --- a/src/main/java/io/qdrant/client/QdrantGrpcClient.java +++ b/src/main/java/io/qdrant/client/QdrantGrpcClient.java @@ -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; } @@ -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) { @@ -231,6 +234,8 @@ private static ManagedChannel createChannel( channelBuilder.usePlaintext(); } + channelBuilder.userAgent(userAgent); + return channelBuilder.build(); } }