Akka Monitoring With Kamon and SPM
With SPM and Kamon you get out of the box metrics about Akka Actors, Dispatchers and Routers, about the JVMs your Akka app runs in, and system metrics.
Join the DZone community and get the full member experience.
Join For FreeSPM provides Akka monitoring via Kamon and has been doing that for quite a while now. With SPM and Kamon you get out of the box metrics about Akka Actors, Dispatchers, and Routers, about the JVMs your Akka app runs in, and system metrics.
We’ve recently made a few nice improvements that should be of interest to anyone using Akka, and especially those using Play! Framework.
Want to see a demo and don’t feel like reading?
Go to https://apps.sematext.com/demo and look for any SPM apps with “Akka” in their name.
Want to see an example Akka app that uses Kamon SPM backend for monitoring?
See https://github.com/sematext/kamon-spm-example/
Transaction Traces, Trace Segments, and Errors
We’ve expanded our Transaction Tracing support and now support Kamon’s Traces and Trace Segments. Note that Traces don’t necessarily have to be initiated by an HTTP request. SPM’s Transaction Tracing lets you specify where a transaction starts. You can see that in our Demo Akka App, which is not actually a web app, so we specified where in code its transactions start and end. Traces can be produced by instrumentation libraries like ‘kamon-play’ or manually in the code using something like this:
val tContext = Kamon.tracer.newContext("name")
And for segments:
val segment = tContext.startSegment("some-section", "business-logic", "kamon")
// your code that is a part of this transaction would be here
segment.finish()
tContext.finish()
So what exactly do these Akka monitoring reports look like? Here are some examples:
Trace response time for AWS/ECS request trace
Slowest traces
Trace and trace segment information
SPM will also show you charts with the number of transaction errors if you are using Kamon 0.6.3 or newer:
To enable this in your app just add the following to your application.conf (see example application.conf):
trace = [ "**" ]
trace-segment = [ "**" ]
And add
"org.apache.thrift" % "libthrift" % "0.9.2"
to your dependencies in build.sbt.
If you are using Maven just add the following to your pom.xml:
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.9.2</version>
</dependency>
Play! Framework Monitoring
Kamon includes a kamon-play module, which ships with bytecode instrumentation aimed at automatic traces and segments management and automatic trace token propagation to your Play! applications. SPM now has support for that, too, and now reports with traces, HTTP error counts, trace response times, and throughput.
To enable this in your Play! app just add the following to your application.conf (see example application.conf):
trace = [ "**" ]
trace-segment = [ "**" ]
http-server = [ "**" ]
Add “org.apache.thrift” % “libthrift” % “0.9.2” to dependencies
And follow instructions from: http://kamon.io/integrations/web-and-http-toolkits/play/
Better Memory Monitoring
For any apps that run on the JVM SPM will give you out of the box reports for various JVM metrics, like garbage collection counts and latency, size and utilization of every JVM memory pool, and JVM thread counts. For Akka apps we go a bit further and provide additional reports for JVM heap and non-heap memory as well as class loading. Here are some samples:
To get these reports you don’t have to do anything — you’ll get them out of the box.
Custom Metrics Monitoring
Besides giving you out the box monitoring with a number of integrations, you can also send custom metrics to SPM. They can be performance metrics, business metrics, or really anything you want to graph, alert on, stick on dashboards, correlate with other metrics or logs (see Logsene!) and so on. You can now send Custom Metrics via Kamon, too.
To start sending metrics to SPM, just add the following to kamon.spm.subscriptions {…} (see example application.conf):
histogram = [ "**" ]
min-max-counter = [ "**" ]
gauge = [ "**" ]
counter = [ "**" ]
What do you get with that? You get custom histograms on whichever metrics you send:
…. or custom counters:
We hope Sematext Akka monitoring helps you optimize run your Akka and Play apps better and faster!
Published at DZone with permission of Stefan Thies, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Mastering Go-Templates in Ansible With Jinja2
-
Constructing Real-Time Analytics: Fundamental Components and Architectural Framework — Part 2
-
Event-Driven Architecture Using Serverless Technologies
-
Introduction to Domain-Driven Design
Comments