+ All Categories
Home > Software > How to ditch the debugger and use logging instead - devwinter 2015

How to ditch the debugger and use logging instead - devwinter 2015

Date post: 16-Jul-2015
Category:
Upload: skelton-thatcher-consulting-ltd
View: 767 times
Download: 0 times
Share this document with a friend
Popular Tags:
83
How to ditch the debugger and use logging instead Matthew Skelton & Rob Thatcher, Skelton Thatcher Consulting /dev/winter 2015, Saturday 24 th January, Cambridge, UK #devwinter
Transcript
Page 1: How to ditch the debugger and use logging instead - devwinter 2015

How to ditch the debugger and use logging instead

Matthew Skelton & Rob Thatcher, Skelton Thatcher Consulting

/dev/winter 2015,

Saturday 24th January, Cambridge, UK

#devwinter

Page 2: How to ditch the debugger and use logging instead - devwinter 2015

Event tracingVagrant + ELK

Demo: no debugging

Page 3: How to ditch the debugger and use logging instead - devwinter 2015

Skelton ThatcherIntroduction and Services Overview

Page 4: How to ditch the debugger and use logging instead - devwinter 2015

‘Cloud’ changes the way we mustdesign, deliver, and operate

our software systems

Page 5: How to ditch the debugger and use logging instead - devwinter 2015

Changes for ‘cloud’

Page 6: How to ditch the debugger and use logging instead - devwinter 2015

Event tracing

Page 7: How to ditch the debugger and use logging instead - devwinter 2015

Event type IDsTransaction tracing

Adjusting logging levels

Page 8: How to ditch the debugger and use logging instead - devwinter 2015

Event type IDs

How many event types in your application?

Page 9: How to ditch the debugger and use logging instead - devwinter 2015

Event type IDs

Page 10: How to ditch the debugger and use logging instead - devwinter 2015

Event type IDs

enum

Human-readable sets: unique values, sparse, immutable

C#, Java, Python, node(Ruby, PHP, …)

Page 11: How to ditch the debugger and use logging instead - devwinter 2015

public enum EventID

{

// Badly-initialised logging data

NotSet = 0,

// An unrecognised event has occurred

UnexpectedError = 10000,

ApplicationStarted = 20000,

ApplicationShutdownNoticeReceived = 20001,

PageGenerationStarted = 30000,

PageGenerationCompleted = 30001,

MessageQueued = 40000,

MessagePeeked = 40001,

ItemAddedToBasket = 60001,

ItemRemovedFromBasket = 60002,

CreditCardDetailsSubmitted = 70001,

// ...

}

Page 12: How to ditch the debugger and use logging instead - devwinter 2015

Technical

Domain

public enum EventID

{

// Badly-initialised logging data

NotSet = 0,

// An unrecognised event has occurred

UnexpectedError = 10000,

ApplicationStarted = 20000,

ApplicationShutdownNoticeReceived = 20001,

PageGenerationStarted = 30000,

PageGenerationCompleted = 30001,

MessageQueued = 40000,

MessagePeeked = 40001,

ItemAddedToBasket = 60001,

ItemRemovedFromBasket = 60002,

CreditCardDetailsSubmitted = 70001,

// ...

}

Page 13: How to ditch the debugger and use logging instead - devwinter 2015

ItemAddedToBasket = 60001

Page 14: How to ditch the debugger and use logging instead - devwinter 2015

ItemAddedToBasket = 60001

Page 15: How to ditch the debugger and use logging instead - devwinter 2015

ItemAddedToBasket = 60001

Page 16: How to ditch the debugger and use logging instead - devwinter 2015

Transaction tracing

Page 17: How to ditch the debugger and use logging instead - devwinter 2015

Monolith to microservices:debugger does not have the full view

Distributed systems

Page 18: How to ditch the debugger and use logging instead - devwinter 2015

Even with remote debugger, it’s boring to attach and detach

Remote debugging?

Page 19: How to ditch the debugger and use logging instead - devwinter 2015
Page 20: How to ditch the debugger and use logging instead - devwinter 2015

Transaction tracing

Unique-ish identifier assigned to web request

Passed through downstream layers

Page 21: How to ditch the debugger and use logging instead - devwinter 2015

What about APM?

APM gives us application insightBUT

How much do we learn? Is APM available on the Dev box?

It’s not just ‘an Ops problem’!

Page 22: How to ditch the debugger and use logging instead - devwinter 2015

Minimal viable tracing?

Helps us to understand how the software really works

Small overhead is worth it

Page 23: How to ditch the debugger and use logging instead - devwinter 2015

Which log level is right?

DEBUG, INFO, WARNING, ERROR, CRITICAL

Page 24: How to ditch the debugger and use logging instead - devwinter 2015

Which log level is right?

Log level should *not* be fixed at compile or build time!

Page 25: How to ditch the debugger and use logging instead - devwinter 2015

<?xml version="1.0" encoding="utf-8" ?>

<Application.EventMappings>

<Events>

<Event Type="CacheServiceStarted">

<Severity Type="Information"/>

</Event>

<Event Type="PageCachePurged">

<Severity Type="Debug"/>

<Enabled="false"/>

</Event>

<Event Type="DatabaseConnectionTimeOut">

<Severity Type="Error"/>

</Event>

</Events>

</Application.EventMappings>

Page 26: How to ditch the debugger and use logging instead - devwinter 2015

Tune log levels

Page 27: How to ditch the debugger and use logging instead - devwinter 2015

Tune log levels

Page 28: How to ditch the debugger and use logging instead - devwinter 2015

Tune log levels

Page 29: How to ditch the debugger and use logging instead - devwinter 2015

Tune log levels

http://bit.ly/TuneLoggingLevels

Page 30: How to ditch the debugger and use logging instead - devwinter 2015

Dev and Ops collaboration*

* and testers too!

Page 31: How to ditch the debugger and use logging instead - devwinter 2015
Page 32: How to ditch the debugger and use logging instead - devwinter 2015

Event tracing

Use enumerations (or closest thing)

Technical and Domain event types

Distributed systems: debuggers less useful

Trace calls with ‘unique-enough’ handles

Tune log levels via config

Page 33: How to ditch the debugger and use logging instead - devwinter 2015

Vagrant + ELK

Page 34: How to ditch the debugger and use logging instead - devwinter 2015

Log AggregationElasticsearch, Logstash & Kibana

Vagrant

Page 35: How to ditch the debugger and use logging instead - devwinter 2015

Log Aggregation

Page 36: How to ditch the debugger and use logging instead - devwinter 2015

Multiple log sourcesMany logs in one place

SearchableTime Sequenced

Page 37: How to ditch the debugger and use logging instead - devwinter 2015
Page 38: How to ditch the debugger and use logging instead - devwinter 2015
Page 39: How to ditch the debugger and use logging instead - devwinter 2015
Page 40: How to ditch the debugger and use logging instead - devwinter 2015
Page 41: How to ditch the debugger and use logging instead - devwinter 2015

What is ELK?

http://www.exploringnature.org/db/detail.php?dbID=43&detID=956

Page 42: How to ditch the debugger and use logging instead - devwinter 2015
Page 43: How to ditch the debugger and use logging instead - devwinter 2015

Vagrant

Page 44: How to ditch the debugger and use logging instead - devwinter 2015

Ruby CLI to deploy Virtual environments

Deploy locally to AWS or Azure etc.

Page 45: How to ditch the debugger and use logging instead - devwinter 2015

Four Simple Steps

$ vagrant box add ubuntu/trusty64$ vagrant init trusty64$ vagrant up$ vagrant ssh

Page 46: How to ditch the debugger and use logging instead - devwinter 2015

RapidRepeatable

Provisioning via scripts ++

Page 47: How to ditch the debugger and use logging instead - devwinter 2015

• Listening to: • Local nginx logs• Local Syslog• (Application logs)

http://bit.ly/velk-demo

Vagrant + ELK Demo VM

Page 48: How to ditch the debugger and use logging instead - devwinter 2015

Elasticsearch, Logstash, Kibana

Page 49: How to ditch the debugger and use logging instead - devwinter 2015
Page 50: How to ditch the debugger and use logging instead - devwinter 2015
Page 51: How to ditch the debugger and use logging instead - devwinter 2015
Page 52: How to ditch the debugger and use logging instead - devwinter 2015
Page 53: How to ditch the debugger and use logging instead - devwinter 2015
Page 54: How to ditch the debugger and use logging instead - devwinter 2015

Recap

Page 55: How to ditch the debugger and use logging instead - devwinter 2015

Aggregated Logging:Vagrant + ELK

Centralised logs, time sequenced, searchableVagrant :quickly spin up & manage machines

ELK : collect, store, display & search logsDeveloper-friendly!

Page 56: How to ditch the debugger and use logging instead - devwinter 2015

Demo: ditching the debugger

Page 57: How to ditch the debugger and use logging instead - devwinter 2015

Vagrant on developer laptopELK for log aggregationWeb app: PHP (Slim)

Event type IDs

Demo: background

Page 58: How to ditch the debugger and use logging instead - devwinter 2015

Use VirtualBoxshared folders

Browse to Kibana UI via NAT-ed interface

Page 59: How to ditch the debugger and use logging instead - devwinter 2015

Event type IDsLog aggregation with ELK

Demo

Page 60: How to ditch the debugger and use logging instead - devwinter 2015
Page 61: How to ditch the debugger and use logging instead - devwinter 2015
Page 62: How to ditch the debugger and use logging instead - devwinter 2015
Page 63: How to ditch the debugger and use logging instead - devwinter 2015
Page 64: How to ditch the debugger and use logging instead - devwinter 2015
Page 65: How to ditch the debugger and use logging instead - devwinter 2015
Page 66: How to ditch the debugger and use logging instead - devwinter 2015
Page 67: How to ditch the debugger and use logging instead - devwinter 2015
Page 68: How to ditch the debugger and use logging instead - devwinter 2015
Page 69: How to ditch the debugger and use logging instead - devwinter 2015
Page 70: How to ditch the debugger and use logging instead - devwinter 2015
Page 71: How to ditch the debugger and use logging instead - devwinter 2015
Page 72: How to ditch the debugger and use logging instead - devwinter 2015
Page 73: How to ditch the debugger and use logging instead - devwinter 2015
Page 74: How to ditch the debugger and use logging instead - devwinter 2015
Page 75: How to ditch the debugger and use logging instead - devwinter 2015
Page 76: How to ditch the debugger and use logging instead - devwinter 2015
Page 77: How to ditch the debugger and use logging instead - devwinter 2015
Page 78: How to ditch the debugger and use logging instead - devwinter 2015
Page 79: How to ditch the debugger and use logging instead - devwinter 2015

Demo: summary

Super-easy to hook application logs into ELK

Sequences of events emerge

Compare timings of events: past and present

Page 80: How to ditch the debugger and use logging instead - devwinter 2015

Recapitulation

Page 81: How to ditch the debugger and use logging instead - devwinter 2015

How to ditch the debuggerUse Vagrant + ELK on development VM

Use a set of event type IDs (enums)Log distinct states of execution

Both technical and domain eventsConsistent event naming helps with searchCompare previous and current executions New logging-fu: make friends with Ops!

Page 82: How to ditch the debugger and use logging instead - devwinter 2015

LinksTune logging levels in Production without recompiling code: http://bit.ly/TuneLoggingLevels

VELK (Vagrant + ELK) demo VM: http://bit.ly/velk-demo

GOOS book (section on logging: p.233-5):http://www.growing-object-oriented-software.com/

Page 83: How to ditch the debugger and use logging instead - devwinter 2015

Thank you!

http://skeltonthatcher.com/

[email protected]

@SkeltonThatcher

+44 (0)20 8242 4103


Recommended