|
147 | 147 | * Reporter calls `telemetry.attach`
|
148 | 148 | * Look in `telemetry.erl`:
|
149 | 149 | * attach stores handler modules with associated events in ETS
|
150 |
| - * execute looks up the handler for the event in ETS and invokes it |
| 150 | + * execute looks up the handler for the event in ETS and invokes it |
151 | 151 | * This is all abstracted away with Telemetry metrics!
|
152 | 152 | * OOTB instrumentation with Elixir Telemetry
|
153 | 153 | * We'll get web requests, database queries, VM monitoring
|
|
161 | 161 | * Tags translate into metric tags (show the mapping)
|
162 | 162 | * Can leverage prefix, global tags, HTTP route tag now more usefully
|
163 | 163 | * Custom instrumentation -> not necessary, any event can be handled by one Telemetry module importing `Telemetry.Metrics`
|
164 |
| - * Define telemetry handler |
165 |
| - * Attach in telemetry module (?) |
166 |
| - * Good candidate--custom interaction error count - log in failure/success? |
167 | 164 | * Instrumentating LiveView with Phoenix's OOTB Telemetry events - CAN'T! Worth noting and comparing to Phoenix channel OOTB telemetry events, link to issue.
|
168 | 165 | * Custom duration and count instrumentation for
|
169 | 166 | * Telemetry under the hood - trace the flow of Phoenix/Ecto/app code emitting event and telemetry looking up event handle and calling it. Look at tags, etc.
|
|
175 | 172 |
|
176 | 173 | ### Ecto Telemetry Event Source Code
|
177 | 174 | * https://github.com/elixir-ecto/ecto/blob/2aca7b28eef486188be66592055c7336a80befe9/lib/ecto/repo.ex#L95
|
| 175 | + |
| 176 | +## To Do |
| 177 | +* Post 1: Intro to Telemetry in Elixir (covers: intro to obs, getting starting with hand-rolled approach, Telemetry under the hood) |
| 178 | + * What is observability/why do we need it? What's so great about getting it with Telemetry lib? |
| 179 | + * DIY metrics with Telemetry lib -> start with dummy Quantum app and emit event for every sign up (counter and duration) |
| 180 | + * Define handler with callback. That callback does some reporting to StatsD, but can dummy this up. |
| 181 | + * Attach handler to event |
| 182 | + * Execute event |
| 183 | + * Under the hood |
| 184 | + * Telemetry attach adds to ETS |
| 185 | + * Telemetry execute looks up handler in ETS and invokes it |
| 186 | +* We need abstraction! Right now, we hand-rolled: |
| 187 | + * Handler module definition and callback |
| 188 | + * Reporting code |
| 189 | + * Calls to attach |
| 190 | + * Even our call to execute seems kind of onerous--plenty of stuff that _everyone_ would want to instrument (HTTP request counts and durations, look at success/failure responses, Ecto query times) |
| 191 | + * Elixir abstracts a lot of this away! |
| 192 | + * Lots of OOTB events emitted--baked in telemetry events executed from Phoenix and Ecto source code and provides a family |
| 193 | + * No need to define custom handlers, reporting logic and enact attach calls thanks to Elixir's family of Telemetry libs--metrics, polling, reporters. |
| 194 | + * Post 2: OTTB Instrumentation with Telemetry Metrics, Polling and Reporters (covers OOTB instrumentation, usage of reporters, adding "custom" events with little effort or custom code) |
| 195 | + * Up and running: |
| 196 | + * Define module that uses telemetry metrics |
| 197 | + * Declare which OOTB events you will listen to in your `metrics` function |
| 198 | + * Start supervisor with Statsd reporter, VM polling in application.ex |
| 199 | + * Closer look at events |
| 200 | + * Each event source code, map execute to metric func, view in statsd and dogstatsd |
| 201 | + * Under the hood to see that reporter calls attach, stores its own module name with event |
| 202 | + * Telemetry calls execute, which looks up handler and invokes `handle_event` |
| 203 | + * Reporter's `handle_event` contains all the statsd/udp logic, uses `metrics` struct definitions to format metrics for statsd and sends traffic |
| 204 | + |
| 205 | +Where to put custom event section? How to sequence "closer look at events" vs. "metrics + reporter under the hood"? Better to see it wired all up and then closer look at events maybe? Maybe keep the hand-rolled sign-in event but get rid of the custom module and attachment call, instead move that into new telemetry module. Then show it all wired up, including looks under the hood. Then replace with OOTB metrics, link to source code, list all helpful metrics. Maybe leave out LV entirely. |
0 commit comments