Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2023-08-23 SpringOne - Observability for Modern...

2023-08-23 SpringOne - Observability for Modern Spring Applications

Jonatan Ivanov

August 26, 2023
Tweet

More Decks by Jonatan Ivanov

Other Decks in Programming

Transcript

  1. SPB2031LV Observability for Modern Spring Applications Staff Software Engineer Tommy

    Ludwig (he/him) #springone #SPB2031LV Staff Software Engineer Jonatan Ivanov (he/him)
  2. Confidential │2023 © VMware, Inc. 2 Disclaimer This presentation may

    contain product features or functionality that are currently under development. This overview of new technology represents no commitment from VMware to deliver these features in any generally available product. Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery. Pricing and packaging for any new features/functionality/technology discussed or presented, have not been determined.
  3. Confidential │2023 © VMware, Inc. 3 Gauge the audience How

    many people are using: Observability in production? Spring Boot 3? Micrometer? OpenTelemetry?
  4. Confidential │2023 © VMware, Inc. 5 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
  5. Confidential │2023 © VMware, Inc. 7 Why do we need

    Observability? Today's systems are increasingly complex (Death Star Architecture, Big Ball of Mud)
  6. Confidential │2023 © VMware, Inc. 8 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)
  7. Confidential │2023 © VMware, Inc. 9 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!
  8. Confidential │2023 © VMware, Inc. 15 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
  9. Confidential │2023 © VMware, Inc. 17 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
  10. Confidential │2023 © VMware, Inc. 19 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
  11. Confidential │2023 © VMware, Inc. 20 Like SLF4J, but for

    metrics… (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
  12. Confidential │2023 © VMware, Inc. 22 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
  13. Confidential │2023 © VMware, Inc. 24 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
  14. Confidential │2023 © VMware, Inc. 25 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(); }
  15. Confidential │2023 © VMware, Inc. 26 Observation API (Micrometer 1.10)

    ObservationRegistry registry = ObservationRegistry.create(); registry.observationConfig() .observationHandler(new MeterHandler(...)) .observationHandler(new TracingHandler(...)) .observationHandler(new LoggingHandler(...)) .observationHandler(new AuditEventHandler(...));
  16. Confidential │2023 © VMware, Inc. 27 Observation API (Micrometer 1.10)

    Observation.createNotStarted("talk", registry) .lowCardinalityKeyValue("conference", "S1") .highCardinalityKeyValue("uid", userId) .observe(this::talk); @Observed
  17. Confidential │2023 © VMware, Inc. 28 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, etc.) Investigating Virtual Treads / Project Loom (?) Investigating Coordinated Restore at Checkpoint (?) New Docs site?