Slide 1

Slide 1 text

Tommy Ludwig (he/him) Jonatan Ivanov (he/him) Observability for Modern Spring Applications

Slide 2

Slide 2 text

What is Observability?

Slide 3

Slide 3 text

What is Observability? (Providing meaningful information about what happens inside) (Data about your app) How well we can understand the internals of a system based on its outputs

Slide 4

Slide 4 text

Why do we need Observability?

Slide 5

Slide 5 text

Why do we need Observability? Today's systems are increasingly complex (Death Star Architecture, Big Ball of Mud)

Slide 6

Slide 6 text

Why do we need Observability? Environments can be chaotic (You turn a knob here a little and services are going down there) We need to deal with unknown unknowns (We can’t know everything) Things can be perceived differently by different observers (Everything is broken for the users but seems ok to you)

Slide 7

Slide 7 text

Why do we need Observability? Business perspective Reduce lost revenue from production incidents •Lower mean time to recovery (MTTR) Require less specialized knowledge for root cause analysis • Shared method of investigating across system Quantify user experience • Don't guess, measure!

Slide 8

Slide 8 text

DEMO github.com/jonatan-ivanov/teahouse

Slide 9

Slide 9 text

Architecture Tea Service Tealeaf Service Water Service

Slide 10

Slide 10 text

Let’s make some tea!

Slide 11

Slide 11 text

TraceID ❮ Exemplars Tags ❯ metrics logs traces through traces

Slide 12

Slide 12 text

Logging Metrics Distributed Tracing

Slide 13

Slide 13 text

Logging - Metrics - Distributed Tracing Logging What happened (why)? Emitting events Metrics What is the context? Aggregating data Distributed Tracing Why happened? Recording causal ordering of events

Slide 14

Slide 14 text

Logging with Spring

Slide 15

Slide 15 text

Logging with Spring Boot: SLF4J + Logback SLF4J with Logback comes pre-configured SLF4J (Simple Logging Façade for Java) Simple API for logging libraries Logback Natively implements the SLF4J API If you want Log4j2 instead of Logback: - spring-boot-starter-logging + spring-boot-starter-log4j2

Slide 16

Slide 16 text

Metrics with Spring

Slide 17

Slide 17 text

Metrics with Spring: Micrometer Dimensional metrics library on the JVM Like SLF4J, but for metrics API is independent of the configured metrics backend Comes with spring-boot-actuator Spring projects are instrumented using Micrometer Many third-party libraries use Micrometer

Slide 18

Slide 18 text

Supported metrics backends AppOptics Atlas Azure Monitor CloudWatch (AWS) Datadog Dynatrace Elastic Ganglia Graphite Humio InfluxDB JMX KairosDB New Relic OpenTSDB OTLP Prometheus SignalFx Stackdriver (GCP) StatsD Wavefront + third-party registries

Slide 19

Slide 19 text

Distributed Tracing with Spring

Slide 20

Slide 20 text

Distributed Tracing with Spring Boot 2.x: Spring Cloud Sleuth Boot 3.x: Micrometer Tracing (Sleuth w/o Spring dependencies) Provide an abstraction layer on top of tracing libraries Brave (OpenZipkin), default OpenTelemetry (CNCF), experimental Instrumentation for Spring Projects, 3rd party libraries, Support for various backends

Slide 21

Slide 21 text

Observation API “Spring Observability”

Slide 22

Slide 22 text

You want to instrument your application… Add logs (application logs) Add metrics Increment Counters Start/Stop Timers Add Distributed Tracing Start/Stop Spans Log Correlation, Context Propagation

Slide 23

Slide 23 text

Observation API (Micrometer 1.10) Observation observation = Observation.start("talk",registry); try { // TODO: scope Thread.sleep(1000); } catch (Exception exception) { observation.error(exception); throw exception; } finally { // TODO: attach tags (key-value) observation.stop(); }

Slide 24

Slide 24 text

Observation API (Micrometer 1.10) ObservationRegistry registry = ObservationRegistry.create(); registry.observationConfig() .observationHandler(new MeterHandler(...)) .observationHandler(new TracingHandler(...)) .observationHandler(new LoggingHandler(...)) .observationHandler(new AuditEventHandler(...));

Slide 25

Slide 25 text

Observation API (Micrometer 1.10) Observation.createNotStarted("talk", registry) .lowCardinalityKeyValue("conference", "S1") .highCardinalityKeyValue("uid", userId) .observe(this::talk); @Observed

Slide 26

Slide 26 text

Micrometer.next (or next.next?) Improved Exemplars support Lots of Observability improvements in the Spring portfolio Better Context Propagation Automatic Log Correlation Additional instrumentations (@Scheduled, R2DBC, JMS, etc.) Investigating Virtual Treads / Project Loom (?) Investigating Coordinated Restore at Checkpoint (?) New Docs site?

Slide 27

Slide 27 text

Stay Connected Let’s continue the conversation Follow us: @TommyLudwig @jonatan_ivanov Visit us at slack.micrometer.io