Monitoring And Metrics With Grails 3 - Object...

Preview:

Citation preview

Monitoring And Metrics With Grails 3

1

© 2016 Object Computing, Inc. (OCI)

All rights reserved. No part of these notes may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior, written permission of Object Computing, Inc. (OCI)

Copyright (c) 2016 Object Computing, Inc. All rights reserved.

Spring 2015, OCI Is Now Home To

Who is OCI We are Software Engineers – St. Louis HQ w/global delivery– 140+ engineers (30% w/Ph.d or Masters)– Average engineer experience >23yrs– Open Source/Standard focused since 1994– Developed and support 12 Free and Open

Source Software (FOSS) Projects– Robust Engineer Training Capabilities & Catalog– Secret & Top Secret Security Clearances

3

Copyright (c) 2016 Object Computing, Inc. All rights reserved.

Open Source Technologies

Spring 2015, OCI is now home to

Copyright (c) 2016 Object Computing, Inc. All rights reserved.

Aerospace & Defense

Telecommunications

Financial Services

Others

Information Technology

• dropwizard-metrics Grails 3 Plugin – Meterable – @Metered – @Timed – AST Transformations – etc…

• JMeter • JMX Enabled Services

– jconsole – @ManagedResource

Agenda

6Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

• Grails 3 Plugin • Standard Gradle Dependency In build.gradle

Installing The Plugin

7Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

dependencies { // ... compile ‘org.grails.plugins:dropwizard-metrics:1.0.0.BUILD-SNAPSHOT' }

Meters

8Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

“A meter measures the rate of events over time (e.g., “requests per second”). In addition to the mean rate, meters also track 1-, 5-, and 15-minute moving averages.”

- http://metrics.dropwizard.io/3.1.0/manual/core/

Meterable Trait

9Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

@TestMixin(GrailsUnitTestMixin)class MeterableSpec extends Specification { static doWithSpring = { metricRegistry MetricRegistry } void 'test markMeter method'() { setup: def registry = applicationContext.metricRegistry def obj = new SomeClass() when: obj.someAction() obj.someAction() obj.someAction() then: registry.meter('some meter').count == 3 } }

class SomeClass implements Meterable { def someAction() { markMeter 'some meter' // ... } }

@Metered Annotation

10Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

class SomeMeteredClass { MetricRegistry metricRegistry void someAction() { String name = MetricRegistry.name(SomeMeteredClass, 'some meter') Meter meter = metricRegistry.meter(name) meter.mark() // ... }}

class SomeMeteredClass { @Metered('some meter') void someAction() { // ... } }

Timers

11Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

“A timer is basically a histogram of the duration of a type of event and a meter of the rate of its occurrence.”

- http://metrics.dropwizard.io/3.1.0/manual/core/

@Timed Annotation

12Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

class SomeTimedClass { MetricRegistry metricRegistry void someAction() { String name = MetricRegistry.name(SomeTimedClass, 'some timer') Timer timer = metricRegistry.timer(name) Timer.Context context = timer.time() try { // ... } finally { context.stop() } }}

class SomeTimedClass { @Timed('some timer') void someAction() { // ... } }

Managed Resources

13Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.

@ManagedResourceclass MetricsLoggerService { int highVolumeThreshold = 10 def metricRegistry def logMetrics() { Meter demoMeter = metricRegistry.meter(‘meter name')

def rate = demoMeter.oneMinuteRate if(rate > highVolumeThreshold) { log.warn "High Volume: $rate" } } @ManagedAttribute void setHighVolumeThreshold(int t) { highVolumeThreshold = t } @ManagedAttribute int getHighVolumeThreshold() { highVolumeThreshold } }

Q & A

14Copyright © 2016, by Object Computing, Inc. (OCI). All rights reserved.