killbill/killbill-platform#163 - allow caller to filter logs#203
Draft
xsalefter wants to merge 5 commits into
Draft
killbill/killbill-platform#163 - allow caller to filter logs#203xsalefter wants to merge 5 commits into
xsalefter wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds server-side filtering support for the logger SSE endpoint so callers can restrict streamed log entries using accountId and/or userToken, while preserving connection liveness via heartbeats when filters exclude all entries.
Changes:
- Introduces
LogEntriesFilterto implement OR-based filtering by resolved account record id and/oruserToken. - Updates
LogsSseHandler(and its wiring inActivator) to apply filtering and to emit heartbeats for filtered-out drains. - Adds fast unit tests for filter behavior, slow SSE lifecycle tests, and an HTML demo client.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| osgi-bundles/bundles/logger/src/main/java/org/killbill/billing/osgi/bundles/logger/LogsSseHandler.java | Applies per-connection filtering and improves heartbeat behavior for filtered streams. |
| osgi-bundles/bundles/logger/src/main/java/org/killbill/billing/osgi/bundles/logger/LogEntriesFilter.java | New filter implementation resolving accountId to record id and matching entries via OR logic. |
| osgi-bundles/bundles/logger/src/main/java/org/killbill/billing/osgi/bundles/logger/Activator.java | Wires RecordIdApi into the SSE handler and ensures base activator startup runs. |
| osgi-bundles/bundles/logger/src/test/java/org/killbill/billing/osgi/bundles/logger/TestLogEntriesFilter.java | New fast unit tests validating matching, parameter parsing, and apply/heartbeat-related state. |
| osgi-bundles/bundles/logger/src/test/java/org/killbill/billing/osgi/bundles/logger/TestLogsSseHandler.java | New slow integration tests exercising end-to-end SSE filtering, heartbeat, and Last-Event-ID resume. |
| osgi-bundles/bundles/logger/pom.xml | Adds dependencies needed by new code/tests. |
| osgi-bundles/bundles/logger/html-sse-demo.md | Adds a minimal browser client demo for the SSE endpoint and filters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+47
to
+56
| <dependency> | ||
| <!-- asked by TestLogsSseHandler. Ideally set to scope:test, but maven still complaining --> | ||
| <groupId>com.google.inject</groupId> | ||
| <artifactId>guice</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <!-- asked by TestLogsSseHandler. Ideally set to scope:test, but maven still complaining --> | ||
| <groupId>com.typesafe</groupId> | ||
| <artifactId>config</artifactId> | ||
| </dependency> |
| // | ||
| // http://localhost:8080/killbill-osgi-logger/?accountId -> no filter applied | ||
| // http://localhost:8080/killbill-osgi-logger/?accountId= -> no filter applied | ||
| // http://localhost:8080/killbill-osgi-logger/?accountId=somename -> filter by accountId. Return if matched. If nothing found, then do not return anything (heartbeat) |
| } | ||
| } catch (final IllegalArgumentException ignored) { | ||
| // Invalid UUID format | ||
| logger.info("receive invalid UUID as request parameter"); |
Comment on lines
+441
to
+443
| final String query = queryParams.entrySet().stream() | ||
| .map(e -> e.getKey() + "=" + e.getValue()) | ||
| .collect(Collectors.joining("&")); |
Comment on lines
+514
to
+516
| final String query = queryParams.entrySet().stream() | ||
| .map(e -> e.getKey() + "=" + e.getValue()) | ||
| .collect(Collectors.joining("&")); |
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import jakarta.annotation.Nonnull; |
Comment on lines
+20
to
+21
| import java.util.ArrayList; | ||
| import java.util.List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original ticket : #163 . Filter by
accountIdnot working yet, as described in slack thread. Commits are self-explanatory.