SlideShare a Scribd company logo
1 of 22
Download to read offline
Erin Schnabel @ebullientworks
Know Your (Java) App
Collect metrics with Micrometer
What makes a system (or service) observable?
Workload routing


System health
Service-centric


problem determination
Context + relationships


for end–to-end analysis
Statistics & trends


Analytics
Service is ready


Service is not a zombie
How many times was


method x called?
Method x was called
What happened when


method x was called
Health Checks Distributed Trace
Metrics Log Entries
Metrics: Time series data
How does data change over time?
• Time is the x-axis


• Data collected at regular intervals


• Each measured value appended to the end of a series


• Used for trend analysis, anomaly detection, alerting


Not for debugging, diagnostics, or root cause analysis
Metrics: Dimensions
Filtered/Selective aggregation
http_server_requests_seconds_count{


env="test",


method="GET",


outcome="SUCCESS",


status="200",


uri="/example/prime/{number}",} 5.0


Cardinality: Each unique combination (name & all tag/values) is its own time series
What is Micrometer?
https://micrometer.io -- Open Source metrics library
"Screw gauge" micrometer
Developer API
• Obtain a MeterRegistry


• Create a Meter (name + tag=value combination)


Gauge


Counter


Timer


DistributionSummary
FunctionCounter


FunctionTimer, LongTaskTimer
Counter: increase only → .increment()
1. registry.counter("example.prime.number", "type", "prime");


2. Counter.builder("counter")


.baseUnit("beans")
/
/
optional


.description("a description")
/
/
optional


.tags("region", "test")
/
/
optional


.register(registry);


3. @Counted(value = "metric.all", extraTags = { "region", "test" })
*
*
Timer → .record(duration)
1. registry.timer("my.timer", "region", "test");


2. Timer.builder("my.timer")


.description("description ")
/
/
optional


.tags("region", "test")
/
/
optional


.register(registry);


3. @Timed(value = "call", extraTags = {"region", "test"})
*
*
Working with Timers
1. timer.record(()
-
>
noReturnValue());


2. timer.recordCallable(()
-
>
returnValue());


3. Runnable r = timer.wrap(()
-
>
noReturnValue());


4. Callable c = timer.wrap(()
-
>
returnValue());


5. Sample s = Timer.start(registry); doStuff; s.stop(timer);
Gauge: increase/decrease, observed value
1. List<String> list = registry.gauge("list.size", Tags.of(
.
.
.
),


new ArrayList
<
>
(), List
:
:
size);


2. Gauge.builder("jvm.threads.peak", threadBean, ThreadMXBean
:
:
getPeakThreadCount)


.tags("region", "test")


.description("The peak live thread count
.
.
.
")


.baseUnit(BaseUnits.THREADS)


.register(registry);
FunctionCounter: gauge-like, counter function
1. registry.more().counter(
.
.
.
)


2. FunctionCounter.builder("hibernate.transactions", statistics,


s
-
>
s.getTransactionCount() - s.getSuccessfulTransactionCount())


.tags("entityManagerFactory", sessionFactoryName)


.tags("result", "failure")


.description("The number of transactions we know to have failed")


.register(registry);
FunctionTimer: gauge-like, counter & duration function
1. registry.more().timer(
.
.
.
);


2. FunctionTimer.builder("cache.gets.latency", cache,


c
-
>
c.getLocalMapStats().getGetOperationCount(),


c
-
>
c.getLocalMapStats().getTotalGetLatency(),


TimeUnit.NANOSECONDS)


.tags("name", cache.getName())


.description("Cache gets")


.register(registry);
LongTaskTimer (active count, longest active task)
1. registry.more().longTaskTimer("long.task", "region", "test");


2. LongTaskTimer.builder("long.task")


.description("a description")
/
/
optional


.tags("region", "test")
/
/
optional


.register(registry);


3. @Timed(value = "long.task", extraTags = {"extra", "tag"}, longTask = true)
*
*
Distribution Summary → .record(value), not time
1. registry.summary("name", "region", "test")


2. DistributionSummary.builder("response.size")


.description("a description")
/
/
optional


.baseUnit("bytes") /
/
optional


.tags("region", "test")
/
/
optional


.register(registry);
Library Maintainer API
• Provide a MeterBinder (optional dependency)


• Register library-speci
fi
c metrics


• Quarkus / Spring discover MeterBinder implementations


binder.bindTo(registry)
Configuration and Filtering
• Late-binding con
fi
guration provided by MeterFilter


• Sourced from user code or shared library


• Accept/Deny
fi
lters:
fi
ne-grained control over gathered metrics


• Transform: rename metrics, add/ignore/replace/rename tags


• Customize Timer / Histogram behavior


• Percentiles, quantiles, Service Level Agreement(SLA) boundaries
Monster Combat
https://github.com/ebullient/monster-combat
https://twitter.com/ebullientworks/status/1328835279659085828?s=20


https://jaxenter.com/metrics-dnd-173311.html
Rolling dice
Micrometer:


Dice.setMonitor((k, v) -> {


registry.counter("dice.rolls", "die", k, "face", label(v))


.increment();


});
© 2020 IBM Corporation
Attacks : Hits and Misses
• AC == Armor class




Attacker rolls a d20...




20 – critical hit (HIT)


1 – critical miss (MISS)


• DC == Dif
fi
culty class




Defender rolls a d20...
: oneRound:


Troll(LARGE GIANT){AC:15,HP:84(8d10+40),STR:18(+4),DEX:13(+1),CON:20(+5),INT:7(-2),WIS:9(-1),C


Pit Fiend(LARGE FIEND){AC:19,HP:300(24d10+168),STR:26(+8),DEX:14(+2),CON:24(+7),INT:22(+6),W
: attack: miss: Troll(36) -> Pit Fiend(100)


: attack: miss: Troll(36) -> Pit Fiend(100)


: attack: hit> Troll(36) -> Pit Fiend(97) for 9 damage using Claws[7hit,11(2d6+4)|slashing]


: attack: hit> Pit Fiend(97) -> Troll(10) for 22 damage using Bite[14hit,22(4d6+8)|piercing]


: attack: MISS: Pit Fiend(97) -> Troll(10)


: attack: HIT> Pit Fiend(97) -> Troll(0) for 34 damage using Mace[14hit,15(2d6+8)|bludgeoning]


: oneRound: survivors


Pit Fiend(LARGE FIEND){AC:19,HP:300(24d10+168),STR:26(+8),DEX:14(+2),CON:24(+7),INT:22(+6),W
Micrometer: Timer & Distribution Summary
• Records value


registry.summary("round.attacks",


"hitOrMiss", event.hitOrMiss(),


"attackType", event.getAttackType(),


"damageType", event.getType())


.record((double) event.getDamageAmount());


• Default metrics: count, sum, max


• Optional: cumulative histogram buckets, pre-computed quantile
So many bugs...
There is often no practical way to write tests for all permutations...
This ended up being a problem with the
original conversion from HTML to JSON.
Who wrote this code, anyway?
Questions?

More Related Content

What's hot

はじめてのKrylov部分空間法
はじめてのKrylov部分空間法はじめてのKrylov部分空間法
はじめてのKrylov部分空間法
tmaehara
 

What's hot (20)

Build an Event-driven Microservices with Apache Kafka & Apache Flink with Ali...
Build an Event-driven Microservices with Apache Kafka & Apache Flink with Ali...Build an Event-driven Microservices with Apache Kafka & Apache Flink with Ali...
Build an Event-driven Microservices with Apache Kafka & Apache Flink with Ali...
 
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
 
はじめてのKrylov部分空間法
はじめてのKrylov部分空間法はじめてのKrylov部分空間法
はじめてのKrylov部分空間法
 
Writing and testing high frequency trading engines in java
Writing and testing high frequency trading engines in javaWriting and testing high frequency trading engines in java
Writing and testing high frequency trading engines in java
 
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
 
On-boarding with JanusGraph Performance
On-boarding with JanusGraph PerformanceOn-boarding with JanusGraph Performance
On-boarding with JanusGraph Performance
 
[study] pointer networks
[study] pointer networks[study] pointer networks
[study] pointer networks
 
Ingesting data at scale into elasticsearch with apache pulsar
Ingesting data at scale into elasticsearch with apache pulsarIngesting data at scale into elasticsearch with apache pulsar
Ingesting data at scale into elasticsearch with apache pulsar
 
Marp入門
Marp入門Marp入門
Marp入門
 
Machine Learning Night - Preferred Networksの顧客向けプロダクト開発 - 谷脇大輔
Machine Learning Night - Preferred Networksの顧客向けプロダクト開発 - 谷脇大輔Machine Learning Night - Preferred Networksの顧客向けプロダクト開発 - 谷脇大輔
Machine Learning Night - Preferred Networksの顧客向けプロダクト開発 - 谷脇大輔
 
DEIM2022_根岸寛太.pptx
DEIM2022_根岸寛太.pptxDEIM2022_根岸寛太.pptx
DEIM2022_根岸寛太.pptx
 
Raskaudenkeskeytystilastot 2020
Raskaudenkeskeytystilastot 2020Raskaudenkeskeytystilastot 2020
Raskaudenkeskeytystilastot 2020
 
TiDB at PayPay
TiDB at PayPayTiDB at PayPay
TiDB at PayPay
 
SAT/SMT solving in Haskell
SAT/SMT solving in HaskellSAT/SMT solving in Haskell
SAT/SMT solving in Haskell
 
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtcヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
ヤフーのAIプラットフォーム紹介 ~AIテックカンパニーを支えるデータ基盤~ #yjtc
 
Planning for Disaster Recovery (DR) with Galera Cluster
Planning for Disaster Recovery (DR) with Galera ClusterPlanning for Disaster Recovery (DR) with Galera Cluster
Planning for Disaster Recovery (DR) with Galera Cluster
 
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
 
검색엔진과 DB Like 검색의 결과가 다른 이유
검색엔진과 DB Like 검색의 결과가 다른 이유검색엔진과 DB Like 검색의 결과가 다른 이유
검색엔진과 DB Like 검색의 결과가 다른 이유
 
決定木学習
決定木学習決定木学習
決定木学習
 

Similar to Know your app: Add metrics to Java with Micrometer | DevNation Tech Talk

Similar to Know your app: Add metrics to Java with Micrometer | DevNation Tech Talk (20)

Testing in a distributed world
Testing in a distributed worldTesting in a distributed world
Testing in a distributed world
 
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
Logging, tracing and metrics: Instrumentation in .NET 5 and AzureLogging, tracing and metrics: Instrumentation in .NET 5 and Azure
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
 
Hadoop metric을 이용한 알람 개발
Hadoop metric을 이용한 알람 개발Hadoop metric을 이용한 알람 개발
Hadoop metric을 이용한 알람 개발
 
Lightning Fast Monitoring against Lightning Fast Outages
Lightning Fast Monitoring against Lightning Fast OutagesLightning Fast Monitoring against Lightning Fast Outages
Lightning Fast Monitoring against Lightning Fast Outages
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Apache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real TimeApache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real Time
 
Apache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseApache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San Jose
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 
Performance eng prakash.sahu
Performance eng prakash.sahuPerformance eng prakash.sahu
Performance eng prakash.sahu
 
Tamir Dresher - Reactive Extensions (Rx) 101
Tamir Dresher - Reactive Extensions (Rx) 101Tamir Dresher - Reactive Extensions (Rx) 101
Tamir Dresher - Reactive Extensions (Rx) 101
 
Rx 101 Codemotion Milan 2015 - Tamir Dresher
Rx 101   Codemotion Milan 2015 - Tamir DresherRx 101   Codemotion Milan 2015 - Tamir Dresher
Rx 101 Codemotion Milan 2015 - Tamir Dresher
 
Metabolomic Data Analysis Workshop and Tutorials (2014)
Metabolomic Data Analysis Workshop and Tutorials (2014)Metabolomic Data Analysis Workshop and Tutorials (2014)
Metabolomic Data Analysis Workshop and Tutorials (2014)
 
Qtp Training
Qtp TrainingQtp Training
Qtp Training
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
Sumo Logic Quickstart - Jan 2017
Sumo Logic Quickstart - Jan 2017Sumo Logic Quickstart - Jan 2017
Sumo Logic Quickstart - Jan 2017
 
Instrumentation and measurement
Instrumentation and measurementInstrumentation and measurement
Instrumentation and measurement
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
I Can See Clearly Now - Observing & understanding your Spring applications at...
I Can See Clearly Now - Observing & understanding your Spring applications at...I Can See Clearly Now - Observing & understanding your Spring applications at...
I Can See Clearly Now - Observing & understanding your Spring applications at...
 
Sumo Logic QuickStart Webinar
Sumo Logic QuickStart WebinarSumo Logic QuickStart Webinar
Sumo Logic QuickStart Webinar
 
Big data at experimental facilities
Big data at experimental facilitiesBig data at experimental facilities
Big data at experimental facilities
 

More from Red Hat Developers

More from Red Hat Developers (20)

DevNation Tech Talk: Getting GitOps
DevNation Tech Talk: Getting GitOpsDevNation Tech Talk: Getting GitOps
DevNation Tech Talk: Getting GitOps
 
Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on Kubernetes
 
GitHub Makeover | DevNation Tech Talk
GitHub Makeover | DevNation Tech TalkGitHub Makeover | DevNation Tech Talk
GitHub Makeover | DevNation Tech Talk
 
Quinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
Quinoa: A modern Quarkus UI with no hassles | DevNation tech TalkQuinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
Quinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
 
Extra micrometer practices with Quarkus | DevNation Tech Talk
Extra micrometer practices with Quarkus | DevNation Tech TalkExtra micrometer practices with Quarkus | DevNation Tech Talk
Extra micrometer practices with Quarkus | DevNation Tech Talk
 
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
 
Integrating Loom in Quarkus | DevNation Tech Talk
Integrating Loom in Quarkus | DevNation Tech TalkIntegrating Loom in Quarkus | DevNation Tech Talk
Integrating Loom in Quarkus | DevNation Tech Talk
 
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
 
Containers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech TalkContainers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech Talk
 
Distributed deployment of microservices across multiple OpenShift clusters | ...
Distributed deployment of microservices across multiple OpenShift clusters | ...Distributed deployment of microservices across multiple OpenShift clusters | ...
Distributed deployment of microservices across multiple OpenShift clusters | ...
 
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
 
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
 
11 CLI tools every developer should know | DevNation Tech Talk
11 CLI tools every developer should know | DevNation Tech Talk11 CLI tools every developer should know | DevNation Tech Talk
11 CLI tools every developer should know | DevNation Tech Talk
 
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
A Microservices approach with Cassandra and Quarkus | DevNation Tech TalkA Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
 
GitHub Actions and OpenShift: ​​Supercharging your software development loops...
GitHub Actions and OpenShift: ​​Supercharging your software development loops...GitHub Actions and OpenShift: ​​Supercharging your software development loops...
GitHub Actions and OpenShift: ​​Supercharging your software development loops...
 
To the moon and beyond with Java 17 APIs! | DevNation Tech Talk
To the moon and beyond with Java 17 APIs! | DevNation Tech TalkTo the moon and beyond with Java 17 APIs! | DevNation Tech Talk
To the moon and beyond with Java 17 APIs! | DevNation Tech Talk
 
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
 
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
 
Kubernetes configuration and security policies with KubeLinter | DevNation Te...
Kubernetes configuration and security policies with KubeLinter | DevNation Te...Kubernetes configuration and security policies with KubeLinter | DevNation Te...
Kubernetes configuration and security policies with KubeLinter | DevNation Te...
 
Level-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
Level-up your gaming telemetry using Kafka Streams | DevNation Tech TalkLevel-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
Level-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Know your app: Add metrics to Java with Micrometer | DevNation Tech Talk

  • 1. Erin Schnabel @ebullientworks Know Your (Java) App Collect metrics with Micrometer
  • 2. What makes a system (or service) observable? Workload routing 
 System health Service-centric 
 problem determination Context + relationships 
 for end–to-end analysis Statistics & trends 
 Analytics Service is ready 
 Service is not a zombie How many times was 
 method x called? Method x was called What happened when 
 method x was called Health Checks Distributed Trace Metrics Log Entries
  • 3. Metrics: Time series data How does data change over time? • Time is the x-axis • Data collected at regular intervals • Each measured value appended to the end of a series • Used for trend analysis, anomaly detection, alerting Not for debugging, diagnostics, or root cause analysis
  • 5. What is Micrometer? https://micrometer.io -- Open Source metrics library "Screw gauge" micrometer
  • 6. Developer API • Obtain a MeterRegistry • Create a Meter (name + tag=value combination) Gauge Counter Timer DistributionSummary FunctionCounter FunctionTimer, LongTaskTimer
  • 7. Counter: increase only → .increment() 1. registry.counter("example.prime.number", "type", "prime"); 2. Counter.builder("counter") 
 .baseUnit("beans") / / optional 
 .description("a description") / / optional 
 .tags("region", "test") / / optional 
 .register(registry); 3. @Counted(value = "metric.all", extraTags = { "region", "test" }) * *
  • 8. Timer → .record(duration) 1. registry.timer("my.timer", "region", "test"); 2. Timer.builder("my.timer") 
 .description("description ") / / optional 
 .tags("region", "test") / / optional 
 .register(registry); 3. @Timed(value = "call", extraTags = {"region", "test"}) * *
  • 9. Working with Timers 1. timer.record(() - > noReturnValue()); 
 2. timer.recordCallable(() - > returnValue()); 
 3. Runnable r = timer.wrap(() - > noReturnValue()); 
 4. Callable c = timer.wrap(() - > returnValue()); 
 5. Sample s = Timer.start(registry); doStuff; s.stop(timer);
  • 10. Gauge: increase/decrease, observed value 1. List<String> list = registry.gauge("list.size", Tags.of( . . . ), 
 new ArrayList < > (), List : : size); 2. Gauge.builder("jvm.threads.peak", threadBean, ThreadMXBean : : getPeakThreadCount) 
 .tags("region", "test") 
 .description("The peak live thread count . . . ") 
 .baseUnit(BaseUnits.THREADS) 
 .register(registry);
  • 11. FunctionCounter: gauge-like, counter function 1. registry.more().counter( . . . ) 2. FunctionCounter.builder("hibernate.transactions", statistics, 
 s - > s.getTransactionCount() - s.getSuccessfulTransactionCount()) 
 .tags("entityManagerFactory", sessionFactoryName) 
 .tags("result", "failure") 
 .description("The number of transactions we know to have failed") 
 .register(registry);
  • 12. FunctionTimer: gauge-like, counter & duration function 1. registry.more().timer( . . . ); 2. FunctionTimer.builder("cache.gets.latency", cache, 
 c - > c.getLocalMapStats().getGetOperationCount(), 
 c - > c.getLocalMapStats().getTotalGetLatency(), 
 TimeUnit.NANOSECONDS) 
 .tags("name", cache.getName()) 
 .description("Cache gets") 
 .register(registry);
  • 13. LongTaskTimer (active count, longest active task) 1. registry.more().longTaskTimer("long.task", "region", "test"); 2. LongTaskTimer.builder("long.task") 
 .description("a description") / / optional 
 .tags("region", "test") / / optional 
 .register(registry); 3. @Timed(value = "long.task", extraTags = {"extra", "tag"}, longTask = true) * *
  • 14. Distribution Summary → .record(value), not time 1. registry.summary("name", "region", "test") 2. DistributionSummary.builder("response.size") 
 .description("a description") / / optional 
 .baseUnit("bytes") / / optional 
 .tags("region", "test") / / optional 
 .register(registry);
  • 15. Library Maintainer API • Provide a MeterBinder (optional dependency) • Register library-speci fi c metrics 
 • Quarkus / Spring discover MeterBinder implementations binder.bindTo(registry)
  • 16. Configuration and Filtering • Late-binding con fi guration provided by MeterFilter • Sourced from user code or shared library 
 • Accept/Deny fi lters: fi ne-grained control over gathered metrics • Transform: rename metrics, add/ignore/replace/rename tags • Customize Timer / Histogram behavior • Percentiles, quantiles, Service Level Agreement(SLA) boundaries
  • 18. Rolling dice Micrometer: 
 Dice.setMonitor((k, v) -> { registry.counter("dice.rolls", "die", k, "face", label(v)) .increment(); });
  • 19. © 2020 IBM Corporation Attacks : Hits and Misses • AC == Armor class 
 
 Attacker rolls a d20... 
 
 20 – critical hit (HIT) 
 1 – critical miss (MISS) • DC == Dif fi culty class 
 
 Defender rolls a d20... : oneRound: Troll(LARGE GIANT){AC:15,HP:84(8d10+40),STR:18(+4),DEX:13(+1),CON:20(+5),INT:7(-2),WIS:9(-1),C Pit Fiend(LARGE FIEND){AC:19,HP:300(24d10+168),STR:26(+8),DEX:14(+2),CON:24(+7),INT:22(+6),W : attack: miss: Troll(36) -> Pit Fiend(100) : attack: miss: Troll(36) -> Pit Fiend(100) : attack: hit> Troll(36) -> Pit Fiend(97) for 9 damage using Claws[7hit,11(2d6+4)|slashing] : attack: hit> Pit Fiend(97) -> Troll(10) for 22 damage using Bite[14hit,22(4d6+8)|piercing] : attack: MISS: Pit Fiend(97) -> Troll(10) : attack: HIT> Pit Fiend(97) -> Troll(0) for 34 damage using Mace[14hit,15(2d6+8)|bludgeoning] : oneRound: survivors Pit Fiend(LARGE FIEND){AC:19,HP:300(24d10+168),STR:26(+8),DEX:14(+2),CON:24(+7),INT:22(+6),W
  • 20. Micrometer: Timer & Distribution Summary • Records value 
 registry.summary("round.attacks", "hitOrMiss", event.hitOrMiss(), "attackType", event.getAttackType(), "damageType", event.getType()) .record((double) event.getDamageAmount()); • Default metrics: count, sum, max • Optional: cumulative histogram buckets, pre-computed quantile
  • 21. So many bugs... There is often no practical way to write tests for all permutations... This ended up being a problem with the original conversion from HTML to JSON. Who wrote this code, anyway?