liveBook · Manning

B2I ratio

As explained in Cloud Observability in Action

The B2I ratio is the number of lines of code after instrumentation divided by the number of lines of code before instrumentation.

The business logic to instrumentation (B2I) ratio measures instrumentation cost by dividing lines of code after instrumentation by lines of code before it. A ratio of 1 represents no added code; higher values indicate more instrumentation code. section 2.2

B2I = LOC_AFTER_INSTRUMENTATION/LOC_BEFORE_INSTRUMENTATION

Calculate the ratio as LOC_AFTER_INSTRUMENTATION divided by LOC_BEFORE_INSTRUMENTATION. section 2.2

Comparing signal types

A service with 3,800 original lines and 400 added instrumentation lines has a B2I ratio of 1.105. In a 24-line example, logs produce a ratio of 1.33, metrics 2, and traces 2.79 when their instrumentation is isolated. section 2.2 section 2.4.3 section 2.3.3 section 2.5.3

Use the ratio as a practical comparison signal, with these qualifications:

  • Choose consistently whether telemetry libraries such as an OpenTelemetry SDK count; excluding dependencies and focusing on application code is a pragmatic option. section 2.2
  • Use it for regression validation rather than as an absolute measure of instrumentation quality or over-instrumentation. section 2.2
  • Interpret higher ratios alongside maintainability, runtime overhead, sampling, cardinality, and telemetry collection costs. section 2.4.3 section 2.5.3

How Cloud Observability in Action covers it

How deep it goes
Defines the formula, works through signal-specific LOC examples, and stops short of judging instrumentation quality.
Examples
Uses 3,800-and-400 LOC, 24-line service, and separate log, metric, and trace instrumentation examples.
What you can do after
Evaluate instrumentation regressions with a rough LOC-based comparison while accounting for measurement boundaries and operational costs.
How it connects
Connects instrumentation with logs, metrics, traces, observability, telemetry libraries, cardinality, and sampling.

Related concepts

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