Skip to content

Add truncated message for request-response-message#358

Merged
skjolber merged 10 commits intomainfrom
truncated
Apr 30, 2026
Merged

Add truncated message for request-response-message#358
skjolber merged 10 commits intomainfrom
truncated

Conversation

@skjolber
Copy link
Copy Markdown
Contributor

@skjolber skjolber commented Apr 29, 2026

When body maxSize is reached, it is truncated. Show this in message field so it is easy to see.

The current approach with writing a notification message at the end of the document does not work too well.

New approach:

OK http://localhost:40845/api/document/some/bigResponse (in 25 ms) [truncated ~124KB]

Also fix some minor bugs, maxSize vs maxBodySize and pretty-printing limit check fail.

Copilot AI review requested due to automatic review settings April 29, 2026 14:34
@skjolber skjolber requested review from a team as code owners April 29, 2026 14:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the request/response logging sinks so that when a body is truncated at maxSize/maxBodySize, the log message text explicitly indicates truncation (e.g., ...[truncated ~124KB]) instead of relying on an appended body message.

Changes:

  • Introduces a truncated value on request/response markers and plumbs it through sinks/markers into MessageComposer.
  • Updates on-demand and eager logbook sinks/markers to compute and propagate truncation size.
  • Adds/updates example endpoints/tests to generate large responses for manual/integration verification.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/AbstractLogLevelSink.java Propagates truncation from marker into message composition.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/AbstractLogLevelLogstashLogbackSink.java Computes truncation for eager markers and returns new marker type.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/AbstractSingleFieldAppendingMarker.java Base marker now carries truncation value.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/LogLevelLogstashLogbackSink.java Passes truncation into request/response marker constructors.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/MessageComposer.java Appends truncation suffix to request/response log messages.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/RequestResponseSingleFieldAppendingMarker.java New common marker base that stores truncation metadata.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/RequestSingleFieldAppendingMarker.java Accepts truncation value and forwards to base marker.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/ResponseSingleFieldAppendingMarker.java Accepts truncation value and forwards to base marker.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/ondemand/AbstractOndemandSingleFieldAppendingMarker.java On-demand marker base now stores truncation metadata.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/ondemand/OndemandLogLevelLogstashLogbackSink.java Computes truncation for on-demand writers and passes it to markers.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/ondemand/RequestOndemandSingleFieldAppendingMarker.java Accepts truncation value and forwards to base.
request-response/logbook/src/main/java/no/entur/logging/cloud/logbook/ondemand/ResponseOndemandSingleFieldAppendingMarker.java Accepts truncation value and forwards to base.
request-response/logbook/src/test/java/no/entur/logging/cloud/logbook/AbstractLogLevelLogstashLogbackSinkTest.java Updates expectations for new marker factory signature/truncation argument.
request-response/logbook-test/src/main/java/no/entur/logging/cloud/logbook/logbook/test/PrettyPrintingLogLevelLogstashLogbackSink.java Passes truncation through pretty-printing marker factory.
request-response/logbook-test/src/main/java/no/entur/logging/cloud/logbook/logbook/test/PrettyPrintingRequestSingleFieldAppendingMarker.java Accepts truncation value.
request-response/logbook-test/src/main/java/no/entur/logging/cloud/logbook/logbook/test/PrettyPrintingResponseSingleFieldAppendingMarker.java Accepts truncation value.
request-response/logbook-test/src/main/java/no/entur/logging/cloud/logbook/logbook/test/PrettyPrintingSink.java Updates overridden message methods to include truncation param.
request-response/logbook-test/src/main/java/no/entur/logging/cloud/logbook/logbook/test/ondemand/PrettyPrintingOndemandLogLevelLogstashLogbackSink.java Computes/passes truncation in pretty-printing on-demand sink.
examples/gcp-web-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Adjusts big response payload shape to exercise truncation.
examples/gcp-web-example/src/test/java/org/entur/example/web/WebLoggingFormatWithBigResponsesTest.java Adds a sleep in test path after big response call.
examples/gcp-web-without-test-artifacts-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Adds a big-response endpoint to produce large JSON responses.
examples/gcp-web-without-test-artifacts-example/src/test/java/org/entur/example/web/WebLoggingFormatWithBigResponsesTest.java Adds an integration test hitting the big-response endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

skjolber and others added 2 commits April 29, 2026 16:53
…org/entur/example/web/rest/DocumentEndpoint.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

skjolber and others added 4 commits April 30, 2026 09:45
…org/entur/example/web/WebLoggingFormatWithBigResponsesTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@skjolber skjolber merged commit 08ace9e into main Apr 30, 2026
9 checks passed
@skjolber skjolber deleted the truncated branch April 30, 2026 11:25
skjolber added a commit that referenced this pull request Apr 30, 2026
* Add truncated message for request-response-message (#358)

* Add truncate message for request-response-logging

* Fix truncated length message

* Adjust

* Adjust

* QA

* Update examples/gcp-web-without-test-artifacts-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* adjust javadoc

* Adjust

* Update examples/gcp-web-without-test-artifacts-example/src/test/java/org/entur/example/web/WebLoggingFormatWithBigResponsesTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Adjust test method name

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

5 participants