Course contentsShow
← System Design
Lesson 1224 of 1,91931. Observability: TracingFree lesson

Automatic vs Manual Instrumentation

Comparing frameworks that auto-instrument common libraries versus explicit span creation for custom application logic.

Automatic vs Manual Instrumentation

What you'll learn: How tracing frameworks can automatically capture spans for common operations versus when you need to explicitly create spans for custom logic.

The Two Approaches to Creating Spans

When building distributed tracing into your system, you have two ways to generate spans:

Automatic instrumentation means frameworks detect and wrap common libraries (HTTP clients, database drivers, message queues) to create spans without code changes. The tracing library intercepts these operations and automatically records timing, metadata, and context propagation.

Manual instrumentation means you explicitly create spans in your code to track custom business logic, internal functions, or application-specific workflows that frameworks can't automatically detect.

When to Use Each

Think of automatic instrumentation like smart assistants at major checkpoints — they greet every visitor (HTTP request) and track their journey through standard hallways (database calls, external APIs). Manual instrumentation is like placing assistants in your organization's unique rooms where custom work happens.

Use automatic instrumentation for:

  • HTTP/gRPC requests and responses
  • Database queries (SQL, NoSQL)
  • Message queue operations
  • Common framework operations (Spring, Express)

Use manual instrumentation for:

  • Business-critical operations you want to measure
  • Complex algorithms or data processing
  • Internal service boundaries
  • Custom caching or queuing logic

The Hybrid Approach

Most production systems combine both. Automatic instrumentation gives you instant visibility into 80% of operations. Manual instrumentation fills gaps in business-critical paths, letting you add custom attributes, track domain-specific metrics, or segment complex operations into meaningful sub-spans.

Key Takeaway: Automatic instrumentation provides baseline observability for standard operations instantly, while manual instrumentation lets you trace custom business logic and add domain-specific context that frameworks cannot infer automatically.