www.erlang-solutions.com
Elixir with
Datadog
Ludwik Bukowski
ludwik.bukowski@erlang-solutions.com
EMPEX
Los Angeles 2019
www.erlang-solutions.com
www.erlang-solutions.com
www.erlang-solutions.com
graphQL
www.erlang-solutions.com
Absinthe
www.erlang-solutions.com
www.erlang-solutions.com
Need of Observability
www.erlang-solutions.com
Need of Observability
Metrics!
www.erlang-solutions.com
Need of Observability
www.erlang-solutions.com
Datadog
- Metrics
- Tracing
- Logs
- Analysis
www.erlang-solutions.com
Metrics - method
Agent
www.erlang-solutions.com
Metrics - method
Agent
- Statix library
www.erlang-solutions.com
Statix library
Statix.increment("hits", 1, [])
-----------> counter
Statix.gauge("cpu_usage", 0.83, [])
-----------> gauge
Statix.histogram("online_users", 123, [])
-----------> histogram
https://github.com/lexmag/statix
www.erlang-solutions.com
www.erlang-solutions.com
www.erlang-solutions.com
www.erlang-solutions.com
Metrics - instrumentation
www.erlang-solutions.com
Metrics - instrumentation
Measure two times; in the beginning of
plugs pipeline and just before sending
response back to the user
Use:
Plug.Conn.register_before_send/2
Phoenix
www.erlang-solutions.com
Metrics - instrumentation
request
response
Plug A
Plug B
Plug C
Plug D
...
Phoenix
www.erlang-solutions.com
Metrics - instrumentation
request
response
Plug A
Plug B
Plug C
Plug D
...
Start Time←
← Calculate diff← End time ←
www.erlang-solutions.com
Metrics - instrumentation
www.erlang-solutions.com
Metrics - instrumentation
www.erlang-solutions.com
Metrics - instrumentation
www.erlang-solutions.com
Metrics - instrumentation
For Controllers and Views’
instrumentation use built-in Phoenix
instrumentation
Use:
config :realworld, RealWorld.Endpoint,
instrumenters: [RealWorld.Phoenix.Instrumenter]
www.erlang-solutions.com
Metrics - instrumentation
Register callback for LogEntry structure. The
structure has fields: query_time, queue_time,
queue_time
Use:
config :real_world, RealWorld.Repo,
loggers: [
{RealWorld.Metrics, :record_metric,[]} ]
Ecto
www.erlang-solutions.com
Metrics - instrumentation
config :real_world, RealWorld.Repo,
loggers: [
{RealWorld.Metrics, :record_metric,[]} ]
www.erlang-solutions.com
Need of Observability
www.erlang-solutions.com
time
www.erlang-solutions.com
Flame
graph!
time
www.erlang-solutions.com
Spandex library
- Each query is a new Trace
- Trace have spans. Spans have metadata
- Spans storage in process dictionary or in ETS
- start_span/1, finish_span/1
https://github.com/spandex-project/spandex
Tracing - method
www.erlang-solutions.com
Tracing - instrumentation
request
response
Spandex.Plug.StartTrace
Plug B
Plug C
Spandex.Plug.EndTrace
...
Phoenix/Plug
www.erlang-solutions.com
Tracing - instrumentation
request
response
Spandex.Plug.StartTrace
Plug B
Plug C
Spandex.Plug.EndTrace
...
Use spandex_phoenix library
Phoenix/Plug
www.erlang-solutions.com
Tracing - instrumentation
Absinthe
www.erlang-solutions.com
Tracing - instrumentation
start span
www.erlang-solutions.com
Tracing - instrumentation
end span
www.erlang-solutions.com
Tracing - instrumentation
Create span before field is resolved and
finish it after the resolution.
Use:
Implement Middleware behaviour
Absinthe
www.erlang-solutions.com
Tracing - instrumentation
www.erlang-solutions.com
Tracing - instrumentation
www.erlang-solutions.com
Tracing - instrumentation
Register callback for LogEntry structure. The
structure has fields: query_time, queue_time,
queue_time. Artificially create a span, i.e
update its start end finish times.
Use:
Spandex.update_span/1
Ecto
www.erlang-solutions.com
Tracing - instrumentation
Ecto
www.erlang-solutions.com
Tracing - instrumentation
Ecto
www.erlang-solutions.com
Tracing - instrumentation
Ecto
www.erlang-solutions.com
Tracing - instrumentation
Ecto
www.erlang-solutions.com
Tracing - instrumentation
Ecto
Use spandex_ecto library
www.erlang-solutions.com
Tracing - instrumentation
Simply wrap function calls with
start_span/1 and finish_span/1 using
decoration.
Use:
@decorate annotation
https://github.com/arjan/decorator
Custom code
www.erlang-solutions.com
...
@decorate tracer(:cache)
def get_from_cache(key) do
val = Cachex.get(:my_cache, key)
{:ok, val}
end
https://github.com/arjan/decorator
Tracing - instrumentation
Custom code
www.erlang-solutions.com
...
@decorate tracer(:cache)
def get_from_cache(key) do
val = Cachex.get(:my_cache, key)
{:ok, val}
end
https://github.com/arjan/decorator
Tracing - instrumentation
Custom code
www.erlang-solutions.com
Tracing - instrumentation
https://github.com/arjan/decorator
Custom code
www.erlang-solutions.com
Tracing - instrumentation
https://github.com/arjan/decorator
Custom code
www.erlang-solutions.com
- Number of traces/number of spans sent should be controlled. Configurable in
spandex (batch_size and sync_threshold options)
- Metadata size consumes network between node and agent and agent and
datadog
- How track asynchronously spawned processes
- For query that involves more than one node distributed tracing in spandex can
be used.
- Tracing overhead. Few hundreds spans per trace still consumes few
milliseconds per query, measured with xprof
https://github.com/Appliscale/xprof
- Telemetry integration ?
Tracing - issues
www.erlang-solutions.com
others
- Great Datadog support team
- Events, monitors, logs and analysis
www.erlang-solutions.com
Thank you
www.erlang-solutions.com
DON’T BE JELLO.
ACCELERATE WITH OUR
ELIXIR ARCHITECTURE
SESSIONS
www.erlang-solutions.com/solutions/
elixir-development
Thank you

More Related Content

PPTX
First order logic
PPTX
Complex Network Analysis
PPTX
Simple overview of machine learning
PPT
Genetic Algorithms
PPT
Version spaces
PPTX
Hybrid systems
PPTX
Algorithm
First order logic
Complex Network Analysis
Simple overview of machine learning
Genetic Algorithms
Version spaces
Hybrid systems
Algorithm

What's hot (20)

PPT
Artificial Intelligence 1 Planning In The Real World
PPT
system analysis and design Chap002
PPTX
Mining Association Rules in Large Database
PPTX
Introduction to MapReduce
PDF
Module 2: Machine Learning Deep Dive
PPTX
Kruskal Algorithm
PPTX
Machine learning
PPTX
Semantic Networks
PDF
Lecture2 big data life cycle
PPT
0/1 knapsack
PPTX
AI3391 Artificial Intelligence Session 20 partially observed games.pptx
PDF
Deck 11
PDF
Ai lecture 01(unit02)
PPTX
Data Science Training | Data Science For Beginners | Data Science With Python...
PDF
DQN (Deep Q-Network)
PPT
Slide3.ppt
PPTX
Data Wrangling
DOCX
Artificial Intelligence Lab File
PDF
Big Data & Analytics (Conceptual and Practical Introduction)
PPTX
Predicates and Quantifiers
Artificial Intelligence 1 Planning In The Real World
system analysis and design Chap002
Mining Association Rules in Large Database
Introduction to MapReduce
Module 2: Machine Learning Deep Dive
Kruskal Algorithm
Machine learning
Semantic Networks
Lecture2 big data life cycle
0/1 knapsack
AI3391 Artificial Intelligence Session 20 partially observed games.pptx
Deck 11
Ai lecture 01(unit02)
Data Science Training | Data Science For Beginners | Data Science With Python...
DQN (Deep Q-Network)
Slide3.ppt
Data Wrangling
Artificial Intelligence Lab File
Big Data & Analytics (Conceptual and Practical Introduction)
Predicates and Quantifiers
Ad

Similar to Datadog and Elixir with Erlang Solutions (20)

PDF
Distributed tracing with erlang/elixir
PDF
Instrumentation & the Pitfalls of Abstraction
PDF
How to measure everything - a million metrics per second with minimal develop...
PDF
Naked Performance With Clojure
PDF
Introduction to Snabbkaffe
 
PDF
PubNative Tracker
PDF
Go Observability (in practice)
PDF
Time-evolving Graph Processing on Commodity Clusters: Spark Summit East talk ...
PDF
Introducing Elixir and OTP at the Erlang BASH
PPTX
Tools for Making Machine Learning more Reactive
PDF
0.5mln packets per second with Erlang
PDF
Implementing GraphQL API in Elixir – Victor Deryagin
PPTX
Practical SPARQL Benchmarking Revisited
PDF
FOSDEM 2019: M3, Prometheus and Graphite with metrics and monitoring in an in...
PDF
Максим Харченко. Erlang lincx
PDF
0.5mln packets per second with Erlang
KEY
Generating and Analyzing Events
PPTX
0.5mln packets per second with Erlang
PDF
Ashwin_Thesis
PDF
Logs, Metrics, traces and Mayhem - An Interactive Observability Adventure Wor...
Distributed tracing with erlang/elixir
Instrumentation & the Pitfalls of Abstraction
How to measure everything - a million metrics per second with minimal develop...
Naked Performance With Clojure
Introduction to Snabbkaffe
 
PubNative Tracker
Go Observability (in practice)
Time-evolving Graph Processing on Commodity Clusters: Spark Summit East talk ...
Introducing Elixir and OTP at the Erlang BASH
Tools for Making Machine Learning more Reactive
0.5mln packets per second with Erlang
Implementing GraphQL API in Elixir – Victor Deryagin
Practical SPARQL Benchmarking Revisited
FOSDEM 2019: M3, Prometheus and Graphite with metrics and monitoring in an in...
Максим Харченко. Erlang lincx
0.5mln packets per second with Erlang
Generating and Analyzing Events
0.5mln packets per second with Erlang
Ashwin_Thesis
Logs, Metrics, traces and Mayhem - An Interactive Observability Adventure Wor...
Ad

More from Erlang Solutions (8)

PDF
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
PDF
Strategies for successfully adopting Elixir
PPTX
RabbitMQ vs Apache Kafka Part II Webinar
PDF
RabbitMQ vs Apache Kafka - Part 1
PDF
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
PDF
Building the ideal betting stack | London Erlang User Group presentation
PDF
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
PDF
Empowering mobile first workers in emerging-markets using messaging
Fintech_Trends_for_2022_report_by_Erlang_Solutions.pdf
Strategies for successfully adopting Elixir
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka - Part 1
Designing & architecting RabbitMQ engineered systems - Ayanda Dube @ London R...
Building the ideal betting stack | London Erlang User Group presentation
Efficient Erlang - Performance and memory efficiency of your data by Dmytro L...
Empowering mobile first workers in emerging-markets using messaging

Recently uploaded (20)

PDF
Architecture types and enterprise applications.pdf
PPTX
Configure Apache Mutual Authentication
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Microsoft Excel 365/2024 Beginner's training
Architecture types and enterprise applications.pdf
Configure Apache Mutual Authentication
Final SEM Unit 1 for mit wpu at pune .pptx
sbt 2.0: go big (Scala Days 2025 edition)
NewMind AI Weekly Chronicles – August ’25 Week III
Benefits of Physical activity for teenagers.pptx
A proposed approach for plagiarism detection in Myanmar Unicode text
1 - Historical Antecedents, Social Consideration.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
A comparative study of natural language inference in Swahili using monolingua...
CloudStack 4.21: First Look Webinar slides
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
The influence of sentiment analysis in enhancing early warning system model f...
Flame analysis and combustion estimation using large language and vision assi...
Hindi spoken digit analysis for native and non-native speakers
A contest of sentiment analysis: k-nearest neighbor versus neural network
Custom Battery Pack Design Considerations for Performance and Safety
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Microsoft Excel 365/2024 Beginner's training

Datadog and Elixir with Erlang Solutions