Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ dependencies {
compile("io.springfox:springfox-swagger2:" + SPRINGFOX_VERSION)
compile("io.springfox:springfox-swagger-ui:" + SPRINGFOX_VERSION)

compile('org.springframework.boot:spring-boot-starter-actuator')
compile("io.micrometer:micrometer-spring-legacy:latest.release")
compile("io.micrometer:micrometer-registry-prometheus:1.0.4")

compileOnly('org.projectlombok:lombok')

runtimeOnly name: 'frontend'
Expand All @@ -49,4 +53,4 @@ afterEvaluate {
jar {
baseName = 'spring-react'
version = '0.0.1'
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
package com.allstate.springreact.controller;

import com.allstate.springreact.domain.InitialState;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
class StateController {
private Counter counter;

@Autowired
public StateController(MeterRegistry registry) {
/*
This value is already exposed under the 'http_server_requests_seconds_count' metric,
but I wanted to show how to wire up a counter if desired
*/
counter = Counter.builder("initial-endpoint-call-count").register(registry);
}

@GetMapping("/state")
public InitialState getInitialCountRequest() {
counter.increment();
InitialState state = new InitialState();
state.setText("Spring-React is wired up!");
state.setValue(7);
Expand Down
17 changes: 17 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
spring.application.name: spring-react

server:
port: ${PORT:8080}

# Enable the /prometheus endpoint to be publicly accessible
endpoints:
prometheus:
sensitive: false

management.metrics:
distribution:
# Enable publishing of histogram metrics to allow for computing aggregable percentile approximations
percentiles-histogram[http.server.requests]: true
# Publish the median and 95th percentile values
percentiles[http.server.requests]: 0.5, 0.95
tags:
# Add a custom label to each metric name to differentiate from other services
application: ${spring.application.name}