Skip to content

Commit

Permalink
feat: add OpenApiStatisticsController
Browse files Browse the repository at this point in the history
  • Loading branch information
pj-cegeka committed Oct 3, 2023
1 parent 264db04 commit a622128
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package be.vlaanderen.informatievlaanderen.ldes.server.admin.rest.controllers;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@SuppressWarnings("java:S2479") // whitespace needed for examples
@Tag(name = "Statistics")
public interface OpenApiStatisticsController {

@Operation(summary = "Retrieve json with statistics of the LDES server")
@ApiResponse(responseCode = "200", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = String.class), examples = @ExampleObject(value = """
{
"ingested member count": 4018,
"current member count": 4018,
"LDESes": [
{
"name": "mobility-hindrances",
"ingested member count": 4018,
"current member count": 4018,
"views": [
{
"name": "mobility-hindrances/timebased",
"fragmentations": [
{
"name": "HierarchicalTimeBasedFragmentation",
"properties": {
"maxGranularity": "minute",
"fragmentationPath": "http://www.w3.org/ns/prov#generatedAtTime"
}
}
],
"fragmentation progress": 100
}
]
}
]
}
""")),
})
String getStatistics();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

@RestController
@RequestMapping(value = "/admin/api/v1/statistics")
public class StatisticsController {
public class StatisticsController implements OpenApiStatisticsController {

private final StatisticsService statisticsService;

public StatisticsController(StatisticsService statisticsService) {
this.statisticsService = statisticsService;
}

@GetMapping
public String getEventStreams() {
@GetMapping(produces = { "application/json" })
public String getStatistics() {
return statisticsService.getMetrics().toString();
}
}

0 comments on commit a622128

Please sign in to comment.