Skip to content

deepgarg-visa/oreilly-live-training

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Recipes

This repository contains the code for the Spring Recipes live training on the O'Reilly platform.

Getting Started

  • Spring Initializr
  • Code Structure
    • Avoid default package
    • Main application class should live in the same package as the rest of your code
    • Use packages to organize your code
      • package by layer
      • package by feature
    • Post class / record
    • Logging
    • DevTools
    • Dependency Injection

Web Applications

  • Building a REST API
  • Validating Data
  • HTTP Clients
    • RestTemplate
    • RestClient
    • Http Interfaces

Databases

  • Connecting to an H2 database
  • What about a real database?
    • Docker Compose Module
    • How to view the database?
  • Database Abstractions
    • JdbcTemplate
    • JdbcClient
    • Spring Data

Spring Cloud

  • Actuator
  • Observability
  • Gateway

The Gateway service is in its own repository to simplify the demo.

Actuator

Observability

Observability was one of the major themes in Spring Framework 6 + Spring Boot 3

  • Java 17
  • Jakarta EE
  • Observability
  • Spring Native (AOT)

What is observability? In our understanding, it is "how well you can understand the internals of your system by examining its outputs". We believe that the interconnection between metrics, logging, and distributed tracing gives you the ability to reason about the state of your system in order to debug exceptions and latency in your applications.

Spring Boot 3 adds numerous autoconfigurations for improved metrics with Micrometer and new distributed tracing support with Micrometer Tracing (formerly Spring Cloud Sleuth). We have been changing the Micrometer API a lot over the course of this year. The most important change is that we have introduced a new API: the Observation API. The idea of its founding was that we want the users to instrument their code once using a single API and have multiple benefits out of it (e.g. metrics, tracing, logging).

Distributed Architecture comes with its challenges: A single user request can travel through hundreds or thousands of microservices. So to quickly identify where things are going wrong, you need a central overview of how requests are performing across services.

Documentation

Observability

  • Log Aggregation (Loki / Logstash)
  • Distributed Tracing (Zipkin / Jaeger)
  • Time Series Metrics (Prometheus)
  • Data Query, Visualization, Alerting (Grafana)

Demo Steps

  • Revisit the Actuator endpoints
    • /metrics endpoint
    • What is being collected by default (http requests, jvm, etc.)
  • Observation API
    • EventController (Observation.createNotStarted)
    • findAll
    • findAllWithDelay
    • findById - add tag
  • @Observed Annotation
    • Add AOP spring boot starter dependency
    • ObservationConfig
    • EventController
      • Replace findAll with annotation to demonstrate different ways to use the API
    • Prometheus
      • Add Prometheus dependency (micrometer-registry-prometheus)
      • Docker Compose
        • service
        • (prometheus.yml)
      • View Prometheus actuator endpoint
      • localhost:9090
    • Grafana
      • Docker Compose
      • Login to Grafana and create a dashboard
    • Zipkin

Security

The Security example is in its own repository to simplify the demo.

Production

  • Configuration
    • Property Sources
    • @Value annotation
    • @ConfigurationProperties
    • Profiles
  • Packaging Options
    • Building an Executable JAR
    • Building a Container Image
    • Building a Native Image
      • Use Cases for Native Images (show off CLI if we have time)
  • Spring Boot 3.2 (Virtual Threads)
  • Deploying your application to...
  • OpenRewrite Demo

Hosts

Here are a few services that you can deploy your Spring Boot Applications on:

Resources

Nate Schutta

Dan Vega

About

O'Reilly Live Training

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%