# Instrumentation

> Adding code to a program so it tells you what it is doing.

**Field:** Infrastructure  
**Category:** Monitoring & Observability  
**Also known as:** Code Instrumentation, Auto-Instrumentation, Zero-Code Instrumentation

## Think of it like

Think of it like fitting sensors to a machine. Then the machine can tell you how it is doing.

## Definition

Instrumentation is adding the code that makes a program send out telemetry. Without it, a program does its job but says nothing about how it went. It can be written by hand, with a few lines that start a timer or count an event. It can also be added with no code changes, by a library or an agent. Most teams start with the automatic kind and add their own where they need more detail.

## Example

Lucy adds one library to her web app. With no other changes, every request now makes a trace that shows the database calls inside it.

## Why it matters

A program can only be watched if it reports. What you add now decides what you see when it breaks.

## Common mistake

Adding it only after an outage. By then, the data from the outage is already gone.

## Three principles

- **Makes it talk.** The program reports what it does.
- **By hand or automatic.** Code you write, or a library.
- **Decides what you see.** Missing data cannot be added later.

## Related terms

- [Telemetry](https://learn.benibix.com/term/infrastructure/telemetry)
- [OpenTelemetry (OTel)](https://learn.benibix.com/term/infrastructure/opentelemetry)
- [Distributed Tracing](https://learn.benibix.com/term/infrastructure/distributed-tracing)
- [Metric (Monitoring)](https://learn.benibix.com/term/infrastructure/metric)
- [Application Performance Monitoring (APM)](https://learn.benibix.com/term/infrastructure/application-performance-monitoring)
- [Logging](https://learn.benibix.com/term/infrastructure/logging)

![An app box on the left with instrumentation code inside. Logs, metrics and traces flow right to a collector, then into stores: a log store searched in one place and a metrics store read by Prometheus through an exporter page. Dashboards and alerts sit at the far right.](https://learn.benibix.com/diagrams/inf4-telemetry-pipeline.svg)

---

Source: https://learn.benibix.com/term/infrastructure/instrumentation
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
