Skip to content

Commit aeca792

Browse files
authored
fix: make flag wasm logger wait (#307)
make flag wasm logger wait
1 parent 9cc72ac commit aeca792

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

openfeature-provider-local/src/main/java/com/spotify/confidence/GrpcWasmFlagLogger.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,25 @@
1515
public class GrpcWasmFlagLogger implements WasmFlagLogger {
1616
private static final String CONFIDENCE_DOMAIN = "edge-grpc.spotify.com";
1717
private static final Logger logger = LoggerFactory.getLogger(GrpcWasmFlagLogger.class);
18-
private final InternalFlagLoggerServiceGrpc.InternalFlagLoggerServiceFutureStub stub;
18+
private final InternalFlagLoggerServiceGrpc.InternalFlagLoggerServiceBlockingStub stub;
1919

2020
public GrpcWasmFlagLogger(ApiSecret apiSecret) {
2121
final var channel = createConfidenceChannel();
2222
final AuthServiceGrpc.AuthServiceBlockingStub authService =
2323
AuthServiceGrpc.newBlockingStub(channel);
2424
final TokenHolder tokenHolder =
2525
new TokenHolder(apiSecret.clientId(), apiSecret.clientSecret(), authService);
26-
final TokenHolder.Token token = tokenHolder.getToken();
2726
final Channel authenticatedChannel =
2827
ClientInterceptors.intercept(channel, new JwtAuthClientInterceptor(tokenHolder));
29-
this.stub = InternalFlagLoggerServiceGrpc.newFutureStub(authenticatedChannel);
28+
this.stub = InternalFlagLoggerServiceGrpc.newBlockingStub(authenticatedChannel);
3029
}
3130

3231
@Override
3332
public void write(WriteFlagLogsRequest request) {
33+
if (request.getClientResolveInfoList().isEmpty() && request.getFlagAssignedList().isEmpty()) {
34+
logger.debug("Skipping empty flag log request");
35+
return;
36+
}
3437
final var ignore = stub.writeFlagLogs(request);
3538
}
3639

0 commit comments

Comments
 (0)