Repository navigation
Conversation
Add session tracking to every application using configureDefaultModules(): - resolve X-Session-Id, X-Request-Id and X-Parent-Request-Id, generate missing identifiers, echo them on the response and expose them through CORS so a browser client can keep its session; - forward the identifiers from createHttpClient(), including the parent request id, so one session can be followed across services; - write one append-only JSONL journal per session and per service through a single background writer with a bounded queue, retention and crash-safe resume; append() never performs file I/O on the request thread and drops on saturation instead of slowing a request; - expose a bearer-protected read API under /v1/session-traces only when a token is configured; - record controller failures through ErrorAttribute so the IN event carries the exception type and message. The ktor module keeps no dependency on exposed or cache: a database-backed SessionStore is supplied by the consumer through SessionConfig.store. Verified with ./gradlew test (all modules), the :ktor:test suite (78 tests), and a two-service example covering success, 500, slow and chained calls, restart persistence, and two 5000-request load runs with 10000 events written and no failures. See guidelines/SESSION_TRACKING.md.
Silence the unused-symbol findings on public framework APIs with @Suppress("unused") and the reason, so a library consumed by downstream projects is not reported as dead code. Fix the real findings at the same time: unused imports, unresolved KDoc links, the deprecated readRemaining() call, and the redundant suspend/runBlocking pair in the argument-resolver test. No behavior change.
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.
Summary
Adds a persistent, zero-configuration session journal to the Ktor module.
X-Session-Id,X-Request-Id,X-Parent-Request-Id: resolved at the edge, generated when absent, echoed on the response, and exposed through CORS.createHttpClient()forwards the identifiers, so a session follows a service-to-service call.$SHIKKANIME_LOGS_DIR/sessions/<service>/<sessionId>.jsonl), written by a single background thread with a bounded queue, retention and crash-safe resume.GET /v1/session-traces/{sessionId}andGET /v1/session-traces, registered only whenSHIKKANIME_SESSION_TOKENis set and protected byAuthorization: Bearer.ErrorAttribute, so theINevent carries the exception type and message.Design
SessionStore.appendoffers to a bounded queue and drops on saturation (droppedEvents); the writer runs at minimum priority.ktormodule keeps no dependency onexposedorcache. A database-backedSessionStoreis supplied by the consumer throughSessionConfig.store; the framework leaves its lifecycle to the caller.[A-Za-z0-9_-]{8,64}is accepted, and a malformed header is replaced rather than used as a path./health,/swagger,/openapi,/v1/session-tracesandOPTIONSare excluded from tracking.SessionConfig(enabled = false)opts out.Verification
./gradlew testall modules: green.:ktor:test: 78 tests.:8080-> catalog:8081),scripts/verify.sh:OUT.requestId == IN.requestId;eventCount=10000,truncated=trueatlimit=1000.Release note
The framework version is bumped to
0.0.27-SNAPSHOT. The snapshot was not published: the available GitHub token only hasread:packages(write:packagesreturns 401). The example uses a Gradle composite build against../framework; a maintainer token withwrite:packagesis needed to publish before consumers can resolve the snapshot.