Faster Java Apps with Opensource APM

A presentation at Bangalore Java User Group August Meetup in August 2019 in Bengaluru, Karnataka, India by Aravind Putrevu

Slide 1

Slide 1

Monitor your Java Apps Elastic APM Aravind Putrevu| Dev Adv | Elastic aravind.dev | @aravindputrevu

Slide 2

Slide 2

What’s Up 2 ● The Stack ● What is APM? ● Why APM? ● What it can do? ● Demo

Slide 3

Slide 3

Elastic Stack SOLUTIONS Elastic Stack Kibana Visualize & Manage Elasticsearch Store, Search, & Analyze Beats SaaS Elastic cloud 3 Logstash SELF-MANAGED Elastic cloud Enterprise Standalone Ingest

Slide 4

Slide 4

Solutions Elastic Stack Logging Metrics APM Security Analytics App Search Site Search Enterprise Search Business Analytics FUTURE Kibana Visualize & Manage Elasticsearch Store, Search, & Analyze Beats SaaS Logstash SELF-MANAGED Ingest

Slide 5

Slide 5

What is APM? In the fields of information technology and systems management, application performance management (APM) is the monitoring and management of performance and availability of software applications. APM is “the translation of IT metrics into business meaning ([i.e.] value).” -Wikipedia 5

Slide 6

Slide 6

6

Slide 7

Slide 7

.. and when this happens… 7

Slide 8

Slide 8

you open these… 8

Slide 9

Slide 9

9

Slide 10

Slide 10

10

Slide 11

Slide 11

What is APM? Application Performance Monitoring 11

Slide 12

Slide 12

Why APM? • APM records traces for database queries, external HTTP requests, and other slow operations that happen during requests to your application ‒ easier to see where your application is spending time • It collects not handled errors and exceptions ‒ easier to debug errors • • 12 Find performance bottlenecks and errors before your customers face them Increase the productivity of your development team

Slide 13

Slide 13

● 100% Open Source ● Readymade UI in Kibana ● Language Agents alpha 13 beta

Slide 14

Slide 14

How it works

Slide 15

Slide 15

Elastic APM Terminology • Service ‒ Set in the APM agent configuration to identify a particular group of APM agents as a single service, a way to logically identify a group of transactions. • Transaction ‒ The requests and responses that compose a service, e.g. the login API call, each made up of individual spans. • Span ‒ A single event within a Transaction such as a Method call, Database query, or Cache insert or retrieval, i.e. anything that takes time to complete. • Errors ‒ Groups of exceptions with matching exception or log messages. 15

Slide 16

Slide 16

Elastic APM Terminology Transaction, trace & span 16

Slide 17

Slide 17

Distributed Tracing 17

Slide 18

Slide 18

APM conceptual allegory Fence jump service: Transaction: 6.5 seconds • • • • 18 fence 1: 1 second fence 2: 2 seconds fence 3: 2 seconds fence 4: 2.5 seconds

Slide 19

Slide 19

APM conceptual allegory Fence jump service: Transaction: 1 second • 19 fence 1 - 1 second and error captured

Slide 20

Slide 20

How to instrument java apps?

  • javaagent java -javaagent:/path/to/elastic-apm-agent-<version>.jar -Delastic.apm.service_name=my-cool-service \ -Delastic.apm.application_packages=org.example,org.another.example -Delastic.apm.server_urls=http://localhost:8200 \ -jar my-application.jar
    20 \

Slide 21

Slide 21

How to instrument java apps?

  • apm-agent-attach.jar java -jar apm-agent-attach.jar —pid <pid> [—args <agent_arguments>] 21

Slide 22

Slide 22

How to instrument java apps? - Programmatic Attach <dependency> <groupId>co.elastic.apm</groupId> <artifactId>apm-agent-attach</artifactId> <version>${elastic-apm.version}</version> </dependency> ElasticApmAttacher.attach(); service_name=my-cool-service application_packages=org.example,org.another.example server_urls=http://localhost:8200 22

Slide 23

Slide 23

How it is working? Simple! Byte-code manipulation 23

Slide 24

Slide 24

What APM can do? 24 • Monitor your application • Trace your code • Reduce overall debugging time

Slide 25

Slide 25

Elastic Cloud {X} Application

Slide 26

Slide 26

Azure/GCP/AWS X Language Application in AKS/GKE/EKS

Slide 27

Slide 27

Elasticsearch on Kubernetes Cluster Any language Application

Slide 28

Slide 28

What you can’t do with APM? • Infrastructure Monitoring • Log analytics • Detect Security Attacks

Slide 29

Slide 29

How Elastic Stack can help you? 29

Slide 30

Slide 30

30

Slide 31

Slide 31

References • https://github.com/elastic/apm-server • https://github.com/elastic/opbeans-java • https://www.elastic.co/webinars/elasticsearch-apm-overview • https://discuss.elastic.co/c/apm ela.st/java-apm bit.ly/learnK8s

Slide 32

Slide 32

Fin! @aravindputrevu