liveBook · Manning

Instrumentation

As explained in Secure APIs

Instrumentation is the practice of preparing software to emit telemetry and collecting that telemetry for analysis.

Instrumentation prepares software to emit telemetry and collects that telemetry for analysis. It makes systems observable, helping detect anomalies and threats; telemetry becomes useful when it is captured, stored, and processed into insights. section 11.3

Instrumentation can be added in two practical ways:

  • Add code that emits specific logs, such as database-query logs, when the required signal is not produced by default. section 11.3
  • Capture request and response logs already produced by web frameworks and store them for analysis. section 11.3
  • Use OTel autoinstrumentation to produce useful signals without code changes by installing dependencies and wiring up the application. section 11.3

FastAPI with OTel

A Python FastAPI application can use OTel’s command-line instrumentation to export traces, metrics, and logs to the console while starting Uvicorn. A generated span can identify a GET /books request and include timing, route, method, host, and status attributes.

How Secure APIs covers it

How deep it goes
Explains manual logging, built-in signals, and zero-code instrumentation, then demonstrates OTel output without detailing telemetry storage or processing.
Examples
Uses database-query logs, web-framework request logs, and an OTel-instrumented FastAPI GET /books span.
What it assumes
Assumes familiarity with applications and telemetry categories while demonstrating setup with Python, FastAPI, Uvicorn, and dependency installation.
What you can do after
Operate OTel autoinstrumentation for a Python FastAPI application and inspect exported traces, metrics, and logs.
How it connects
Connects telemetry with logs, traces, metrics, observability, anomaly detection, threat detection, and autoinstrumentation.

Also explained in

Compare how 13 books explain instrumentation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.