Implement GCZ Log Consumption Services and API with Pagination and Validation (Mock backend MVP)
Objective:
Implement log consumption functionality for the transformer service that allows querying logs by stream type, date range, and keyword, with pagination and validation capabilities.
Technical Requirements:
-
Log Streams: Introduce a dictionary for log streams that includes the following types:
-
transformer
: Transformer application logs. -
ingestion
: Data ingestion process logs. -
trajectory
: Trajectory processing logs. -
provider
: Provider application logs.
-
-
Controller:
- Create a
LogsController
to handle the/logs/{logStream}
endpoint, supporting filtering by:-
fromDate
(optional, flexible format likeyyyy-MM-dd
oryyyy-MM-dd'T'HH:mm:ss.SSSSSS
) -
toDate
(optional) -
keyword
(optional)
-
- Implement pagination for the results, allowing for flexible page size and number.
- Create a
-
Service and Repository:
-
LogsService
: Create a service that processes the log retrieval logic. -
LogsRepository
: Implement a mock repository that returns pre-defined log data for testing, with support for filtering and pagination.
-
-
Validation:
- Add validation for
logStream
to ensure only valid stream types are accepted. - Handle validation errors using a custom global exception handler (
GlobalExceptionMapper
), with detailed error messages when invalid data is provided. - Allow flexible datetime input formats (
yyyy-MM-dd
andyyyy-MM-dd'T'HH:mm:ss.SSSSSS
).
- Add validation for
-
Mock Data:
- Provide mock log data with varied log streams, dates, and severities.
- Ensure pagination works properly with larger datasets.
Acceptance Criteria:
-
Logs can be retrieved by stream, date range, and keyword. -
The system properly handles validation errors for invalid log streams. -
Logs are returned in a paginated format. -
The /logs/streams
endpoint returns all available log streams. -
Flexible date-time formats are supported. -
Unit tests are implemented to cover the functionality and validation.
Edited by Rostislav Dublin (EPAM)