I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1)...
Transcript of I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1)...
![Page 1: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/1.jpg)
CLOJURE SYNTAX PRIMER
(1) Function definition (defn function-name [arg1 arg2 … argn] ;; body )
(2) Function call (function-name arg1 arg2 … argn)
1
(defn- function-name [arg1 arg2 … argn] ;; function call(s) )
(function-name arg1 arg2 … argn)
I will be showing Clojure code, however this is all the syntax you need to understand to be able to read it. p.s No monads :-)
![Page 3: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/3.jpg)
CHAPTER 8 - MONITORING
Monitoring for monolithic architectures Monitoring for microservice architectures Thanks to Sam’s book Introducing the sample app
3
![Page 4: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/4.jpg)
why should I care?
4
![Page 5: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/5.jpg)
(WEB) ARCHITECTURE: PRE 2013
5
Web Server
App Server
DB
Legacy App
![Page 6: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/6.jpg)
MONITORING
6
![Page 7: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/7.jpg)
MONITORING @ SCALE
7
![Page 8: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/8.jpg)
MULTIPLEXING FTW!
8
![Page 9: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/9.jpg)
MATURE TOOLS
9
![Page 10: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/10.jpg)
compared with…
10
![Page 11: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/11.jpg)
(WEB) ARCHITECTURE: PRE 2013
11
Web Server
DB
Legacy App
uSvc uSvc uSvc
uSvc uSvc uSvc
uSvc uSvc uSvc
App Server
![Page 12: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/12.jpg)
(WEB) ARCHITECTURE: 2013-
12
DB
Legacy App
uSvc uSvc uSvc
uSvc uSvc uSvc
uSvc uSvc uSvc
![Page 13: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/13.jpg)
MONITORING MICROSERVICES
13
Complex Architecture
Collaborating Components
Nuanced Failure Modes
![Page 14: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/14.jpg)
Correlation IDs
Synthetic Transactions
Proactive monitoring
14
![Page 15: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/15.jpg)
let’s get practical!
15
![Page 16: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/16.jpg)
OUR SAMPLE APP
16
![Page 17: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/17.jpg)
1. NORMALISE INPUT
macromonitoring4microservices
17
"Macromonitoring 4 Microservices"
![Page 18: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/18.jpg)
2. SPLIT INTO ROWS
macrom onitor ing4mi croser vices
18
macromonitoring4microservices
Length = 29 chars 52 = 25 62 = 36
![Page 19: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/19.jpg)
m a c r o m o n i t o r i n g 4 m i c r o s e r v i c e s
1 2 3 4 5 6
3. READ DOWN THE COLUMNS
macrom onitor ing4mi croser vices
![Page 20: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/20.jpg)
4. CONSTRUCT THE CIPHERTEXT
moicvannricigocrt4seoomesmrir
m a c r o m o n i t o r i n g 4 m i c r o s e r v i c e s
1 2 3 4 5 6
![Page 21: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/21.jpg)
to the code!
21
![Page 22: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/22.jpg)
SERVICES
22
1. Get input 2. Normalise plaintext 3. Split into rows 4. Read down the columns 5. Construct ciphertext 6. Display ciphertext
Front-End (4000)
Back-End (3000)
Normaliser (3002)
Square sizer (3001)
Column handler (3003)
1 6
2
3
4
5
![Page 23: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/23.jpg)
BEWARE OF OVERKILL!
23
Square sizer (3001)
3
![Page 24: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/24.jpg)
CORRELATION IDS
![Page 25: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/25.jpg)
CORRELATION IDS
GUID for all calls pertaining to a single user transaction Generated by first service in call chain Propagated through all downstream calls Challenges: asynchronous services
25
![Page 26: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/26.jpg)
CORRELATION IDS
26
Front-End (4000)
Back-End (3000)
Normaliser (3002)
Square sizer (3001)
Column handler (3003)
Generate Propogate
![Page 27: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/27.jpg)
ID GENERATION
27
Front-End (4000)
“crypto-square-6092d335-57f7-4220-afc7-2f677f9390e6”
Constant
Unique across user transactions
![Page 28: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/28.jpg)
ID PROPOGATION
28
Front-End (4000)
Back-End (3000)
x-correlation-id: crypto-square-6092…90e6
![Page 29: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/29.jpg)
now what?
29
![Page 30: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/30.jpg)
RIEMANN.IO
30
![Page 31: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/31.jpg)
RIEMANN EVENTS
31
(defrecord Event [ service state description metric tags time ttl
“reg1.foo.bar” “reg-service http” “ok” “apache-log” 201 [“reg1” “http”] 104534892 60
![Page 32: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/32.jpg)
CORRELATION IDS
32
Front-End
(4000)
Back-End
(3000)
Normaliser
Square sizer
Column handler (3003)
Riemann
![Page 33: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/33.jpg)
GENERATING EVENTS
33
![Page 34: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/34.jpg)
DEMO!
Correlation IDs allow us to: (1) spot which services participate (ok/fail/warning in which transactions (2) gather relative metrics across transactions
34
![Page 35: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/35.jpg)
corr-id mapping
CHALLENGES
35
Foo Barcorr-id Synchronous
Foo Barcorr-id
corr-id
Asynchronous
![Page 36: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/36.jpg)
SYNTHETIC TRANSACTIONS
![Page 37: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/37.jpg)
SYNTHETIC TRANSACTIONS
Fake transactions injected into production system Sole intention of checking “is the system working?” Reuse functional tests as clients Challenges: excluding from metrics
37
![Page 38: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/38.jpg)
FUNCTIONAL TESTS
38
![Page 39: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/39.jpg)
RUN THE TESTS
39
![Page 40: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/40.jpg)
DEMO!
Synthetic Transactions allow us to: Get confidence that key user transactions are working in production
40
![Page 41: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/41.jpg)
CHALLENGES
41
Are these all real sales?
![Page 42: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/42.jpg)
PROACTIVE MONITORING
![Page 43: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/43.jpg)
PROACTIVE MONITORING - CIRCUIT BREAKERS
(1) Closed: execute (2) Open/Tripped: use fallback (if available) (3) Half-Open: try 1 request Monitors circuit health (error % > threshold %) Help build antifragility
43Source: https://github.com/Netflix/Hystrix/wiki/How-it-Works#CircuitBreaker
![Page 44: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/44.jpg)
HYSTRIX BY NETFLIX
44
![Page 45: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/45.jpg)
in conclusion
45
![Page 46: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/46.jpg)
MONITORING MICROSERVICES
46
Complex Architecture
Collaborating Components
Nuanced Failure Modes
• Correlation IDs
• Synthetic Transactions
• Proactive Monitoring
![Page 47: I will be showing Clojure code, however this is all the ...€¦ · CLOJURE SYNTAX PRIMER (1) Function definition (defn function-name [arg1 arg2 … argn] ;; body ) (2) Function](https://reader036.fdocuments.us/reader036/viewer/2022063008/5fbe8a004c9fe44ced530064/html5/thumbnails/47.jpg)
FINAL THOUGHTS
▫︎Monitoring microservices environments can be tricky
▫︎ Invest in operational capabilities in line with microservices development
▫︎ Reuse OSS from organisations doing this stuff well (e.g., Netflix)
▫︎ Passive/reactive monitoring is necessary, but “failure demand” (aka waste)
47