One thing is common across all organizations, no matter what their technology stack: when the pager goes off, somebody is roused and sat in front of a computer in order to stop the system's bleeding. Root cause analysis will come later; the priority is to restore service. The more we can do upfront to support remediation in those waning and critical seconds, minutes, and hours after a production outage, the better.
Services should expose their own health endpoints, metadata about the service itself, logs, threadumps, configuration and environment information, and whatever else could be operationally useful. Services should also track the progression of both business and operational metrics. Metrics can be overwhelming, and so it makes sense to publish collected metrics to time-series databases that support analytics and visualization. There are many time-series databases like Graphite, Atlas, InfluxDB, and OpenTSDB. Metrics are keys and values over time. Spring Boot suppots the collection of metrics, and can delegate to projects like Dropwizard Metrics and Micrometer.io to publish them.
@SpringBootApplication
public class DemoApplication {
public static void main(String args[]) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
GraphiteReporter graphite(@Value("${graphite.prefix}") String prefix,
@Value("${graphite.url}") URL url,
@Value("${graphite.port}") int port,
MetricRegistry registry) {
GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
.prefixedWith(prefix)
.build(new Graphite(url.getHost(), port));
reporter.start(1, TimeUnit.SECONDS);
return reporter;
}
}
@RestController
class FulfillmentRestController {
@Autowired
private CounterService ok, well, as long as shes able to get a taxi or a bte tocounterService;
@RequestMapping("/customers/{customerId}/fulfillment")
Fulfillment fulfill(@PathVariable long customerId) {
// ..
counterService.increment("meter.customers-fulfilled");
// ..
}
}
Log multiplexers like Logstash or Cloud Foundry's Loggregator funnel the logs from application instances and ship them to downstream log analysis tools like ElasticSearch, Splunk, or PaperTrail.
Getting all of this out of the box is a good start, but not enough. There is often much more to be done before a service can get to production. Spring Boot uses a mechanism called auto-configuration that lets developers codify things — identity provider integrations, connection pools, frameworks, auditing infrastructure, literally anything — and have it stood up as part of the Spring Boot application just by being on the CLASSPATH
if all the conditions stipulated by the auto-configuration are met! These conditions can be anything, and Spring Boot ships with many common and reusable conditions: is a library on the CLASSPATH
? Is a bean of a certain type defined (or not defined)? Is an environment property specified? Starting a new service need not be more complex than a public static void main entry-point and a library on the CLASSPATH
if you use the right technology.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}