Bitpath

Lesson 1 · Unit 04

Instrumenting

Where a span or a metric earns its place, naming, vendor-neutral instrumentation in outline, and sampling.

13 exercisesabout 3 min

What you practise

  • Where a span or a metric earns its place, naming, vendor-neutral instrumentation (OpenTelemetry) in outline, sampling

Try a question from this lesson

Pick one

A date helper runs 40 times per request and takes 2 microseconds. A call to the payment provider runs once and takes 80 to 2,000 ms. You may wrap one in a span. Which?

Hint

Which one could be the answer to "why was this request slow"?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Instrument the boundaries

Put a span where work crosses a boundary: a request arriving, a call going out to a service, a database or a queue. Those are the places that are slow, that fail, and that you do not control.

Metrics: the golden signals for each service, plus a counter for each event the business counts. Code in between rarely needs either.

request in        span + rate, errors,
                  duration
call out (http)   span
database query    span
order placed      counter
a loop, a helper  nothing

Concept

Vendor-neutral instrumentation

If your code calls one company's tracing library, changing company means touching every call. OpenTelemetry is the open standard that prevents this, in three parts.

The API is what your code calls to start a span or record a metric. The SDK batches and samples. An exporter sends the data on, and is picked in configuration.

Libraries for common frameworks can add the boundary spans for you.

your code  ->  API  ->  SDK  ->  exporter
                                    |
                    any backend you choose

Concept

Sampling

Keeping every trace of a busy service costs more than it teaches. Sampling keeps a share.

Head sampling decides when the request starts, usually from the trace id, and passes the verdict along with the context. Whole traces are kept or dropped. It is cheap, and blind: it cannot know the request will fail.

Tail sampling decides after the trace is complete, so it can keep every error. It must hold all spans until then.

head   decide at the start, by trace id
       cheap; errors kept only by luck
tail   decide at the end, by content
       keeps errors; must buffer spans

9 more exercises in the app

  • 4× multiple choice
  • 1× fill the blanks
  • 1× order the lines
  • 2× type the answer
  • 1× true or false

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy