monitoring and metrics with grails 3 - object...

14
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)

Upload: others

Post on 22-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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)

Page 2: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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

Spring 2015, OCI Is Now Home To

Page 3: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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

Page 4: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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

Open Source Technologies

Spring 2015, OCI is now home to

Page 5: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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

Aerospace & Defense

Telecommunications

Financial Services

Others

Information Technology

Page 6: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

• 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.

Page 7: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

• 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' }

Page 8: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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/

Page 9: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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' // ... } }

Page 10: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

@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() { // ... } }

Page 11: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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/

Page 12: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

@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() { // ... } }

Page 13: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

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 } }

Page 14: Monitoring And Metrics With Grails 3 - Object Computinggrailsblog.objectcomputing.com/downloads/MonitoringAnd... · 2019-08-26 · Who is OCI We are Software Engineers – St. Louis

Q & A

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