Skip to content

Commit 50d0c65

Browse files
committed
feat: creat an instance of OpenGemini Client with an interceptor
Signed-off-by: chenhuan <xiangyuyu_2024@qq.com>
1 parent 9e6efb3 commit 50d0c65

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

opengemini-client/src/main/java/io/opengemini/client/impl/OpenGeminiClientFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
import io.opengemini.client.api.BatchConfig;
2222
import io.opengemini.client.api.Configuration;
2323
import io.opengemini.client.api.OpenGeminiException;
24+
import io.opengemini.client.interceptor.Interceptor;
25+
import io.opengemini.client.interceptor.OtelInterceptor;
2426
import org.jetbrains.annotations.NotNull;
2527

28+
import java.util.List;
29+
2630
public class OpenGeminiClientFactory {
2731
public static OpenGeminiClient create(@NotNull Configuration configuration) throws OpenGeminiException {
2832
if (configuration.getAddresses() == null || configuration.getAddresses().isEmpty()) {
@@ -54,4 +58,13 @@ public static OpenGeminiClient create(@NotNull Configuration configuration) thro
5458
}
5559
return new OpenGeminiClient(configuration);
5660
}
61+
62+
public static OpenGeminiClient createClientWithInterceptors(Configuration config) throws OpenGeminiException {
63+
OpenGeminiClient client = create(config);
64+
List<Interceptor> interceptors = List.of(
65+
new OtelInterceptor()
66+
);
67+
client.addInterceptors(interceptors.toArray(new Interceptor[0]));
68+
return client;
69+
}
5770
}

0 commit comments

Comments
 (0)