Skip to content

killbill/killbill-platform#163 - allow caller to filter logs#203

Draft
xsalefter wants to merge 5 commits into
masterfrom
platform-163
Draft

killbill/killbill-platform#163 - allow caller to filter logs#203
xsalefter wants to merge 5 commits into
masterfrom
platform-163

Conversation

@xsalefter

Copy link
Copy Markdown
Contributor

Original ticket : #163 . Filter by accountId not working yet, as described in slack thread. Commits are self-explanatory.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LogEntriesFilter to implement OR-based filtering by resolved account record id and/or userToken.
  • Updates LogsSseHandler (and its wiring in Activator) 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants