SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
Logging in Scala
John Nestor 47 Degrees
www.47deg.com
August 9, 2016
147deg.com
47deg.com © Copyright 2016 47 Degrees
Outline
• Introduction
• Architecture
• Features
• Implementation
• Demos
• Cross Service Log Aggregation
2
Introduction
3
47deg.com © Copyright 2016 47 Degrees
Existing Scala Loggers
• Java loggers (used in Scala code)
• Log4j (used in Spark)
• SLF4J and Logback
• Scala loggers
• Abandoned: Configgy, Logula (Coda Hale)
• Log4s (wraps SLF4J)
• scala-logging (Heiko Seeberger) (wraps Log4j)
• Special Scala loggers
• Akka actor logging (can route to Logback)
• Play logging (uses Logback)
4
47deg.com © Copyright 2016 47 Degrees
Why a New Logger?
• Pure Scala. (No Java code)
• Richer messages (Json rather than text strings)
• Aggregate logs across multiple (micro-)services
• Clean design with rich features
5
47deg.com © Copyright 2016 47 Degrees
New Scala Logger History
• Whitepages Logger - part of a new Scala web service
framework
• Persist Logger (work supported by 47 Degrees)
• clean up and improve API
• removed Whitepages specific stuff
• added complete documentation
• Full source and documentation on Github
• Maven central



"com.persist" % "persist-logging_2.11" % "1.2.4"
• Apache 2 license
6
47deg.com © Copyright 2016 47 Degrees
Rich Logging Example
log.error(s”Too many values Size:${vals.size} Max:${vals.max}”)
log.error(map(“msg”->”Too many values”,

”Size”->vals.size,

”Max”->vals.max),

id=currentId)
{“msg”:”Too Many Values”, “Size”: 10, “Max: “33}
7
Architecture
8
47deg.com © Copyright 2016 47 Degrees
Persist Logger Architecture
9
logging.conf
logback.xml
Scala
Logger API
Slf4j API
Akka Actor
Logging API
Custom
Logback
Appender
LogBack
Custom Akka
Logging Actor
Logging Actor
Stdout
Appender
File
Appender
Kafka
Appender
Other
Appenders
Logger
State
Scala
Logger
Control API
Features
10
47deg.com © Copyright 2016 47 Degrees
API Log Call
• Level
• Rich Message
• Id (optional)
• Per request level control
• Per request log aggregation
• Exception (optional)
• use RichException for a RichMessage
11
47deg.com © Copyright 2016 47 Degrees
Rich Messages
• String
• Int, Long, Float, Double, BigDecimal
• null, Boolean
• Seq[RichMessage]
• Map[String,RichMessage]
12
47deg.com © Copyright 2016 47 Degrees
Why Json?
• Easy to support rich metadata in addition to the
message
• Easier to parse in downstream tools
• No need to manually escape strings
• Naturally supports multiline messages
• Standard text format
• But many internal possibilities
• This logger uses Persist Json (only internally)
• Rich messages use standard Scala types for in
internal API
13
47deg.com © Copyright 2016 47 Degrees
Kind of Logs
• Error log
• Alternative logs
• GC
• Timing (for fine grain timing)
• Server (request-response, duration)
• Client (request, response, duration)
• User defined
14
47deg.com © Copyright 2016 47 Degrees
Standard Fields
• @category (error, gc, …)
• @host
• @service
• @severity (info, debug, warn, error, …)
• @timestamp (msec)
• class, file, line, actor
• msg
• trace (for exceptions, Json)
15
47deg.com © Copyright 2016 47 Degrees
Appenders
• Stdout
• no server/service specific fields
• color (optional)
• summary
• File (daily rotation)
• Kafka
• Custom, user defined
• Control destination
• Control contents and format
16
47deg.com © Copyright 2016 47 Degrees
Level Control
• logging.conf (default options), can override
• uses Typesafe config
• levels: API, SLF4J, Akka
• Change level via API
• Per request custom level
• Custom filters
• Based on level, and content
17
47deg.com © Copyright 2016 47 Degrees
Timing
• Fine grain timing
• Uses request ids to aggregate
• Time in microseconds
• Time log
• Can be used with concurrency (futures and actors)
18
47deg.com © Copyright 2016 47 Degrees
Other Loggers
• Captures messages from other legacy loggers that
might be used in new project libraries
• SLF4J (captured via Logback appender)
• Akka Actor Logging (captured by custom Akka log
handing actor)
19
47deg.com © Copyright 2016 47 Degrees
Look At Documentation
• logging.conf
• Overview
• API
20
Implementation
21
47deg.com © Copyright 2016 47 Degrees
Persist Logger Architecture
22
logging.conf
logback.xml
Scala
Logger API
Slf4j API
Akka Actor
Logging API
Custom
Logback
Appender
LogBack
Custom Akka
Logging Actor
Logging Actor
Stdout
Appender
File
Appender
Kafka
Appender
Other
Appenders
Logger
State
Scala
Logger
Control API
47deg.com © Copyright 2016 47 Degrees
Dealing with Concurrency
• The logging actor provides fully generalized sync
• Serializes output
• Handles filters
• But asking the actor on every message can be slow
• @volatile booleans for each log level associated with
logger
• Note the logger itself is global state
• One copy for entire app, no need to pass a parameter
everywhere: ClassLogging and ActorLogging traits.
• Must start before any messages and stop after any
messages (but there is a development workaround)
• Contains log level booleans
23
47deg.com © Copyright 2016 47 Degrees
Source Location
• Could find using exception stack trace at run-time
• Better solution is to use Scala macro and reflection at
compile-time
24
Demos
25
47deg.com © Copyright 2016 47 Degrees
Demos
• Simple
• Actor
• Exceptions
• Request Id
• Alternative
• Other (Actor, SLF4J)
• Timing
• Filter
• Appender
26
Cross Service Log
Aggregation
27
47deg.com © Copyright 2016 47 Degrees
The Problem
• Applications are being split into ever more micro-
services
• Much harder to answer questions?
• What is the overall control flow for various requests?
• What was the root cause of an error?
• Where are the performance bottlenecks?
• In this talk we look at a prototype system that can be
used to answer these kinds of questions
• Work in progress
28
47deg.com © Copyright 2016 47 Degrees
Related Work
• Google Dapper
• Zipkin
• Akka Tracing (wraps Zipkin)
29
47deg.com © Copyright 2016 47 Degrees
Approach
• Use Scala as much as possible
• Aggregate logs for each independent request across a set of
Scala services
• Provide a basis for both
• Near real-time
• Alerts
• View aggregated logs for any request
• More comprehensive batch analysis
• Failure statistics
• Overall patterns
• Trends over time
30
47deg.com © Copyright 2016 47 Degrees
Overall Architecture
31
Kafka
Spark
Streaming
(Aggregation)
NoSql DB
REST Log
API *
(Merge, Filter)
Services *
* Uses: Persist Service Framework
Persist Service Framework Uses:
Akka HTTP
Persist Json
Persist Logger
Spark Batch
Analytics
47deg.com © Copyright 2016 47 Degrees
Scala REST Service
32
Server
Log
Service
(can be lots of these)
Error
Log
Client
Log
... To Other
Services
Kafka
(only one cluster/topic for all
logs and services)
... From Other
Services
47deg.com © Copyright 2016 47 Degrees
Services
33
Serial
A
Driver
E
D
C
B
Parallel
47deg.com © Copyright 2016 47 Degrees
Aggregation (via Spark Streaming)
• Pass from client to server
• Client name
• Tracking Id
• same for a single request across all micro services
• Span Id
• unique for each call for a given Client-Server pair
• Match Tracking Id and Span Id across
• Client log
• Server log
34
47deg.com © Copyright 2016 47 Degrees
Cross Service Matching
35
Id1
Span1
X
A
Id1
Span1
X
Id1
Span2
A
Id1
Span3
A
A
Id1
Span1
Span2
B
B
Id1
Span2
A
B
Id1
Span3
A
A
Id1
Span1
Span3
B
Match
Match
Match
Match
Service A Service B
47deg.com © Copyright 2016 47 Degrees
Look at Sample Output
• Array of log messages
• Tree of log messages
• Filtered tree with timings
36
Questions
37

Weitere ähnliche Inhalte

Was ist angesagt?

Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPdatamantra
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentationGene Chang
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterKonstantin Tsykulenko
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuHavoc Pennington
 
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Understanding Akka Streams, Back Pressure, and Asynchronous ArchitecturesUnderstanding Akka Streams, Back Pressure, and Asynchronous Architectures
Understanding Akka Streams, Back Pressure, and Asynchronous ArchitecturesLightbend
 
Developing Secure Scala Applications With Fortify For Scala
Developing Secure Scala Applications With Fortify For ScalaDeveloping Secure Scala Applications With Fortify For Scala
Developing Secure Scala Applications With Fortify For ScalaLightbend
 
Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"Markus Jura
 
Introduction to Apache Kafka- Part 2
Introduction to Apache Kafka- Part 2Introduction to Apache Kafka- Part 2
Introduction to Apache Kafka- Part 2Knoldus Inc.
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterKonstantin Tsykulenko
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceTrisha Gee
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsShashank L
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2Gal Marder
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Codemotion
 
Spark real world use cases and optimizations
Spark real world use cases and optimizationsSpark real world use cases and optimizations
Spark real world use cases and optimizationsGal Marder
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016takezoe
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"Gal Marder
 

Was ist angesagt? (20)

Building scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTPBuilding scalable rest service using Akka HTTP
Building scalable rest service using Akka HTTP
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
 
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Understanding Akka Streams, Back Pressure, and Asynchronous ArchitecturesUnderstanding Akka Streams, Back Pressure, and Asynchronous Architectures
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
 
Developing Secure Scala Applications With Fortify For Scala
Developing Secure Scala Applications With Fortify For ScalaDeveloping Secure Scala Applications With Fortify For Scala
Developing Secure Scala Applications With Fortify For Scala
 
Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"Lagom - Mircoservices "Just Right"
Lagom - Mircoservices "Just Right"
 
Introduction to Apache Kafka- Part 2
Introduction to Apache Kafka- Part 2Introduction to Apache Kafka- Part 2
Introduction to Apache Kafka- Part 2
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx France
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
 
Spark real world use cases and optimizations
Spark real world use cases and optimizationsSpark real world use cases and optimizations
Spark real world use cases and optimizations
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
 
JVM languages "flame wars"
JVM languages "flame wars"JVM languages "flame wars"
JVM languages "flame wars"
 

Ähnlich wie Logging in Scala

Introduction to Apache Apex
Introduction to Apache ApexIntroduction to Apache Apex
Introduction to Apache ApexApache Apex
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersAmazon Web Services
 
Scala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataScala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataJohn Nestor
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaMax Alexejev
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure DataTaro L. Saito
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructureharendra_pathak
 
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...apidays
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafkaemreakis
 
Log management with ELK
Log management with ELKLog management with ELK
Log management with ELKGeert Pante
 
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresqlbotsplash.com
 
Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Cask Data
 
Intro to Apache Apex @ Women in Big Data
Intro to Apache Apex @ Women in Big DataIntro to Apache Apex @ Women in Big Data
Intro to Apache Apex @ Women in Big DataApache Apex
 
Adobe Spark Meetup - 9/19/2018 - San Jose, CA
Adobe Spark Meetup - 9/19/2018 - San Jose, CAAdobe Spark Meetup - 9/19/2018 - San Jose, CA
Adobe Spark Meetup - 9/19/2018 - San Jose, CAJaemi Bremner
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014Derek Collison
 
Ingestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexIngestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexApache Apex
 
Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape NETWAYS
 
Technology behind-real-time-log-analytics
Technology behind-real-time-log-analytics Technology behind-real-time-log-analytics
Technology behind-real-time-log-analytics Data Science Thailand
 
Tech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapTech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapAdaCore
 

Ähnlich wie Logging in Scala (20)

Introduction to Apache Apex
Introduction to Apache ApexIntroduction to Apache Apex
Introduction to Apache Apex
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and Containers
 
Scala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataScala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big Data
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Log management with ELK
Log management with ELKLog management with ELK
Log management with ELK
 
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresql
 
Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?
 
Novinky v Oracle Database 18c
Novinky v Oracle Database 18cNovinky v Oracle Database 18c
Novinky v Oracle Database 18c
 
Intro to Apache Apex @ Women in Big Data
Intro to Apache Apex @ Women in Big DataIntro to Apache Apex @ Women in Big Data
Intro to Apache Apex @ Women in Big Data
 
Adobe Spark Meetup - 9/19/2018 - San Jose, CA
Adobe Spark Meetup - 9/19/2018 - San Jose, CAAdobe Spark Meetup - 9/19/2018 - San Jose, CA
Adobe Spark Meetup - 9/19/2018 - San Jose, CA
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
 
Ingestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache ApexIngestion and Dimensions Compute and Enrich using Apache Apex
Ingestion and Dimensions Compute and Enrich using Apache Apex
 
Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape
 
Technology behind-real-time-log-analytics
Technology behind-real-time-log-analytics Technology behind-real-time-log-analytics
Technology behind-real-time-log-analytics
 
Tech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapTech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore Roadmap
 
Spark Uber Development Kit
Spark Uber Development KitSpark Uber Development Kit
Spark Uber Development Kit
 

Mehr von John Nestor

LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing John Nestor
 
Type Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsType Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsJohn Nestor
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patternsJohn Nestor
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaJohn Nestor
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and PerformanceJohn Nestor
 

Mehr von John Nestor (7)

LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing LambdaFlow: Scala Functional Message Processing
LambdaFlow: Scala Functional Message Processing
 
LambdaTest
LambdaTestLambdaTest
LambdaTest
 
Type Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsType Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset Transforms
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patterns
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to Scala
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and Performance
 
Neutronium
NeutroniumNeutronium
Neutronium
 

Kürzlich hochgeladen

Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 

Kürzlich hochgeladen (20)

Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 

Logging in Scala

  • 1. Logging in Scala John Nestor 47 Degrees www.47deg.com August 9, 2016 147deg.com
  • 2. 47deg.com © Copyright 2016 47 Degrees Outline • Introduction • Architecture • Features • Implementation • Demos • Cross Service Log Aggregation 2
  • 4. 47deg.com © Copyright 2016 47 Degrees Existing Scala Loggers • Java loggers (used in Scala code) • Log4j (used in Spark) • SLF4J and Logback • Scala loggers • Abandoned: Configgy, Logula (Coda Hale) • Log4s (wraps SLF4J) • scala-logging (Heiko Seeberger) (wraps Log4j) • Special Scala loggers • Akka actor logging (can route to Logback) • Play logging (uses Logback) 4
  • 5. 47deg.com © Copyright 2016 47 Degrees Why a New Logger? • Pure Scala. (No Java code) • Richer messages (Json rather than text strings) • Aggregate logs across multiple (micro-)services • Clean design with rich features 5
  • 6. 47deg.com © Copyright 2016 47 Degrees New Scala Logger History • Whitepages Logger - part of a new Scala web service framework • Persist Logger (work supported by 47 Degrees) • clean up and improve API • removed Whitepages specific stuff • added complete documentation • Full source and documentation on Github • Maven central
 
 "com.persist" % "persist-logging_2.11" % "1.2.4" • Apache 2 license 6
  • 7. 47deg.com © Copyright 2016 47 Degrees Rich Logging Example log.error(s”Too many values Size:${vals.size} Max:${vals.max}”) log.error(map(“msg”->”Too many values”,
 ”Size”->vals.size,
 ”Max”->vals.max),
 id=currentId) {“msg”:”Too Many Values”, “Size”: 10, “Max: “33} 7
  • 9. 47deg.com © Copyright 2016 47 Degrees Persist Logger Architecture 9 logging.conf logback.xml Scala Logger API Slf4j API Akka Actor Logging API Custom Logback Appender LogBack Custom Akka Logging Actor Logging Actor Stdout Appender File Appender Kafka Appender Other Appenders Logger State Scala Logger Control API
  • 11. 47deg.com © Copyright 2016 47 Degrees API Log Call • Level • Rich Message • Id (optional) • Per request level control • Per request log aggregation • Exception (optional) • use RichException for a RichMessage 11
  • 12. 47deg.com © Copyright 2016 47 Degrees Rich Messages • String • Int, Long, Float, Double, BigDecimal • null, Boolean • Seq[RichMessage] • Map[String,RichMessage] 12
  • 13. 47deg.com © Copyright 2016 47 Degrees Why Json? • Easy to support rich metadata in addition to the message • Easier to parse in downstream tools • No need to manually escape strings • Naturally supports multiline messages • Standard text format • But many internal possibilities • This logger uses Persist Json (only internally) • Rich messages use standard Scala types for in internal API 13
  • 14. 47deg.com © Copyright 2016 47 Degrees Kind of Logs • Error log • Alternative logs • GC • Timing (for fine grain timing) • Server (request-response, duration) • Client (request, response, duration) • User defined 14
  • 15. 47deg.com © Copyright 2016 47 Degrees Standard Fields • @category (error, gc, …) • @host • @service • @severity (info, debug, warn, error, …) • @timestamp (msec) • class, file, line, actor • msg • trace (for exceptions, Json) 15
  • 16. 47deg.com © Copyright 2016 47 Degrees Appenders • Stdout • no server/service specific fields • color (optional) • summary • File (daily rotation) • Kafka • Custom, user defined • Control destination • Control contents and format 16
  • 17. 47deg.com © Copyright 2016 47 Degrees Level Control • logging.conf (default options), can override • uses Typesafe config • levels: API, SLF4J, Akka • Change level via API • Per request custom level • Custom filters • Based on level, and content 17
  • 18. 47deg.com © Copyright 2016 47 Degrees Timing • Fine grain timing • Uses request ids to aggregate • Time in microseconds • Time log • Can be used with concurrency (futures and actors) 18
  • 19. 47deg.com © Copyright 2016 47 Degrees Other Loggers • Captures messages from other legacy loggers that might be used in new project libraries • SLF4J (captured via Logback appender) • Akka Actor Logging (captured by custom Akka log handing actor) 19
  • 20. 47deg.com © Copyright 2016 47 Degrees Look At Documentation • logging.conf • Overview • API 20
  • 22. 47deg.com © Copyright 2016 47 Degrees Persist Logger Architecture 22 logging.conf logback.xml Scala Logger API Slf4j API Akka Actor Logging API Custom Logback Appender LogBack Custom Akka Logging Actor Logging Actor Stdout Appender File Appender Kafka Appender Other Appenders Logger State Scala Logger Control API
  • 23. 47deg.com © Copyright 2016 47 Degrees Dealing with Concurrency • The logging actor provides fully generalized sync • Serializes output • Handles filters • But asking the actor on every message can be slow • @volatile booleans for each log level associated with logger • Note the logger itself is global state • One copy for entire app, no need to pass a parameter everywhere: ClassLogging and ActorLogging traits. • Must start before any messages and stop after any messages (but there is a development workaround) • Contains log level booleans 23
  • 24. 47deg.com © Copyright 2016 47 Degrees Source Location • Could find using exception stack trace at run-time • Better solution is to use Scala macro and reflection at compile-time 24
  • 26. 47deg.com © Copyright 2016 47 Degrees Demos • Simple • Actor • Exceptions • Request Id • Alternative • Other (Actor, SLF4J) • Timing • Filter • Appender 26
  • 28. 47deg.com © Copyright 2016 47 Degrees The Problem • Applications are being split into ever more micro- services • Much harder to answer questions? • What is the overall control flow for various requests? • What was the root cause of an error? • Where are the performance bottlenecks? • In this talk we look at a prototype system that can be used to answer these kinds of questions • Work in progress 28
  • 29. 47deg.com © Copyright 2016 47 Degrees Related Work • Google Dapper • Zipkin • Akka Tracing (wraps Zipkin) 29
  • 30. 47deg.com © Copyright 2016 47 Degrees Approach • Use Scala as much as possible • Aggregate logs for each independent request across a set of Scala services • Provide a basis for both • Near real-time • Alerts • View aggregated logs for any request • More comprehensive batch analysis • Failure statistics • Overall patterns • Trends over time 30
  • 31. 47deg.com © Copyright 2016 47 Degrees Overall Architecture 31 Kafka Spark Streaming (Aggregation) NoSql DB REST Log API * (Merge, Filter) Services * * Uses: Persist Service Framework Persist Service Framework Uses: Akka HTTP Persist Json Persist Logger Spark Batch Analytics
  • 32. 47deg.com © Copyright 2016 47 Degrees Scala REST Service 32 Server Log Service (can be lots of these) Error Log Client Log ... To Other Services Kafka (only one cluster/topic for all logs and services) ... From Other Services
  • 33. 47deg.com © Copyright 2016 47 Degrees Services 33 Serial A Driver E D C B Parallel
  • 34. 47deg.com © Copyright 2016 47 Degrees Aggregation (via Spark Streaming) • Pass from client to server • Client name • Tracking Id • same for a single request across all micro services • Span Id • unique for each call for a given Client-Server pair • Match Tracking Id and Span Id across • Client log • Server log 34
  • 35. 47deg.com © Copyright 2016 47 Degrees Cross Service Matching 35 Id1 Span1 X A Id1 Span1 X Id1 Span2 A Id1 Span3 A A Id1 Span1 Span2 B B Id1 Span2 A B Id1 Span3 A A Id1 Span1 Span3 B Match Match Match Match Service A Service B
  • 36. 47deg.com © Copyright 2016 47 Degrees Look at Sample Output • Array of log messages • Tree of log messages • Filtered tree with timings 36