Skip to content

Commit

Permalink
Merge aa1b696 into 295e898
Browse files Browse the repository at this point in the history
  • Loading branch information
fsjovatsen committed Nov 24, 2019
2 parents 295e898 + aa1b696 commit f11bfc3
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ dependencies {
compile('org.jooq:jool-java-8:0.9.14')

compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-actuator')

compile 'org.springframework.metrics:spring-metrics:0.5.1.RELEASE'
compile 'io.prometheus:simpleclient_common:0.8.0'

testCompile('no.fint:fint-test-utils:0.0.4')
testCompile("cglib:cglib-nodep:${cglibVersion}")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/no/fint/provider/events/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import no.fint.springfox.EnableSpringfoxExtension;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.metrics.export.prometheus.EnablePrometheusMetrics;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableFintAudit
Expand All @@ -19,6 +20,7 @@
))
@SwaggerDefinition(externalDocs = @ExternalDocs(value = "Go to the API list", url = "/api"))
@EnableScheduling
@EnablePrometheusMetrics
@SpringBootApplication
public class Application {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.metrics.annotation.Timed;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

Expand Down Expand Up @@ -45,11 +46,13 @@ public class AdminController {
@Autowired
private DownstreamSubscriber downstreamSubscriber;

@Timed
@GetMapping("/audit/events")
public List<MongoAuditEvent> getAllEvents() {
return mongo.findAll(MongoAuditEvent.class);
}

@Timed
@GetMapping("/audit/events/since/{when}")
public List<MongoAuditEvent> queryEventsSince(@PathVariable String when) {
Duration duration = Duration.parse(when);
Expand All @@ -58,6 +61,7 @@ public List<MongoAuditEvent> queryEventsSince(@PathVariable String when) {
return mongo.find(q, MongoAuditEvent.class);
}

@Timed
@GetMapping("/orgIds")
public List<Map> getOrganizations() {
return adminService.getOrgIds().entrySet().stream().map(entry -> ImmutableMap.of(
Expand All @@ -66,6 +70,7 @@ public List<Map> getOrganizations() {
)).collect(Collectors.toList());
}

@Timed
@GetMapping("/orgIds/{orgId:.+}")
public ResponseEntity getOrganization(@ApiParam(Constants.SWAGGER_X_ORG_ID) @PathVariable String orgId) {
if (adminService.isRegistered(orgId)) {
Expand All @@ -78,6 +83,7 @@ public ResponseEntity getOrganization(@ApiParam(Constants.SWAGGER_X_ORG_ID) @Pat
}
}

@Timed
@PostMapping("/orgIds/{orgId:.+}")
public ResponseEntity registerOrgId(
@ApiParam(Constants.SWAGGER_X_ORG_ID) @PathVariable String orgId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import no.fint.provider.events.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.metrics.annotation.Timed;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -21,6 +22,7 @@ public class EventStateController {
@Autowired
private EventStateService eventStateService;

@Timed
@GetMapping
public Collection<EventState> getEventState() {
return eventStateService.getEventStates();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.metrics.annotation.Timed;
import org.springframework.web.bind.annotation.*;

@Slf4j
Expand All @@ -24,6 +25,7 @@ public class ResponseController {
private ResponseService responseService;

@ApiOperation(value = "", notes = "Receives event object with response data.")
@Timed
@PostMapping
public void response(@ApiParam(Constants.SWAGGER_X_ORG_ID) @RequestHeader(HeaderConstants.ORG_ID) String orgId,
@ApiParam(Constants.SWAGGER_EVENT) @RequestBody Event event) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/no/fint/provider/events/sse/SseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import no.fint.provider.events.subscriber.DownstreamSubscriber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.metrics.annotation.Timed;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

Expand Down Expand Up @@ -41,6 +42,7 @@ public class SseController {
private ProviderProps props;

@ApiOperation(value = "Connect SSE client", notes = "Endpoint to register SSE client.")
@Timed
@GetMapping("/{id}")
public ResponseEntity<SseEmitter> subscribe(
@ApiParam(Constants.SWAGGER_X_ORG_ID) @RequestHeader(HeaderConstants.ORG_ID) String orgId,
Expand All @@ -57,6 +59,7 @@ public ResponseEntity<SseEmitter> subscribe(
}

@ApiOperation(value = "", notes = "Returns all registered SSE clients.")
@Timed
@GetMapping("/clients")
public List<SseOrg> getClients() {
Map<String, FintSseEmitters> clients = sseService.getSseClients();
Expand All @@ -71,12 +74,14 @@ public List<SseOrg> getClients() {
}

@ApiOperation(value = "", notes = "Remove all registered SSE clients.")
@Timed
@DeleteMapping("/clients")
public void removeSseClients() {
sseService.removeAll();
}

@ApiOperation(value = "", notes = "Adapter starts the oauth process")
@Timed
@GetMapping("/auth-init")
public void authorize() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConversionException;
import org.springframework.metrics.annotation.Timed;
import org.springframework.web.bind.annotation.*;

@Slf4j
Expand All @@ -25,6 +26,7 @@ public class StatusController {
private StatusService statusService;

@ApiOperation(value = "", notes = "Post back the event with the status flag telling if the response can be handled or not.")
@Timed
@PostMapping
public void status(@ApiParam(Constants.SWAGGER_X_ORG_ID) @RequestHeader(HeaderConstants.ORG_ID) String orgId,
@ApiParam(Constants.SWAGGER_EVENT) @RequestBody Event event) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ server:
logging:
level:
no.fint.provider.events.sse: DEBUG

management:
# endpoints:
# web:
# exposure:
# include: "*"
# metrics:
# export:
# prometheus:
# enabled: true
#
security:
enabled: false

0 comments on commit f11bfc3

Please sign in to comment.