What Is Manual Instrumentation in OpenTelemetry?

What Is Manual Instrumentation in OpenTelemetry?

Manual instrumentation means adding OpenTelemetry calls by hand inside your own code, so that your program reports exactly the steps, numbers and events you care about. This guide explains it from zero, with analogies, diagrams and real-world patterns.

Imagine you buy a new car with a dashboard. The factory has installed the standard gauges: speed, fuel level and engine temperature. They work the moment you turn the key, and you did nothing to set them up. But suppose you drive a delivery van and you also want to know how many parcels are on board, how many stops remain and how long each stop takes. The factory could never have guessed this. You must add your own sensors and wire them to the dashboard yourself. That hand-fitted extra equipment is the heart of manual instrumentation: the standard gauges come automatically, and the special ones that tell the story of your own business are added by you.

1Why Programs Need to Describe Themselves

A running program is a sealed box, and instrumentation is how we open a window in it.

When a program runs on a server far away, nobody can watch it work. It has no face and cannot tell you how it feels. Yet people need to know what it is doing. Why is the checkout slow today? Which step takes the longest? How many orders failed in the last ten minutes? Without any information coming out of the program, engineers can only guess.

The act of adding code or tools that make a program report on its own behavior is called instrumentation. The word comes from scientific instruments, such as thermometers and pressure gauges, that are attached to a machine so that people can read what is happening inside. The information that comes out is called telemetry, and it usually takes the form of traces, metrics and logs.

Simple Analogy

Think of a hospital patient connected to monitors. The machines read pulse, oxygen and temperature, and send the numbers to a central screen where nurses watch. The machines are the instrumentation, and the numbers are the telemetry. Without them, the nurses would have to stand beside every bed and guess.

Attach
add instrumentation to the program
Emit
the program reports what it does
Understand
people read and act on the data

2A Quick Map of OpenTelemetry

A short refresher on the big picture helps manual instrumentation find its place.

OpenTelemetry, often called OTel, is an open-source project that defines how software describes its own behavior. It is vendor neutral, which means no single monitoring company owns it. It handles three kinds of data, called signals, and provides libraries for many programming languages.

Signal 1

Traces

The journey of one request across services, split into timed steps called spans. They answer where the time went.

Signal 2

Metrics

Numbers measured over time, such as requests per second. They answer how much and how fast.

Signal 3

Logs

Time-stamped records of events. They answer what exactly happened and why.

The API and the SDK

OpenTelemetry deliberately splits its libraries into two layers. The API is a thin set of calls that code uses to create telemetry, such as start a span or record a measurement. On its own, the API does almost nothing and costs almost nothing. The SDK is the real engine that processes the telemetry and exports it to a destination. The application owner installs and configures the SDK, and this split is what makes manual instrumentation safe for shared libraries.

i
Beginner Tip

Remember the pair: the API is the plug on the wall, and the SDK is the power station behind it. Your code only touches the plug. Whoever runs the application decides what is behind it.

3So, What Exactly Is Manual Instrumentation?

It is the practice of writing OpenTelemetry API calls directly in your own code.

Let us define it carefully. Manual instrumentation in OpenTelemetry means that a developer deliberately adds code that uses the OpenTelemetry API to create telemetry at chosen places. The developer decides which operations deserve a span, which numbers deserve a metric, which events deserve a log, and which details deserve to be attached as attributes.

It is called manual because a human writes it, as opposed to automatic instrumentation, where a ready-made tool inserts the telemetry code for you. Manual instrumentation is the most precise and most flexible way to describe your program, because nobody knows your business logic better than you do.

1

Decide what matters

Choose the operations, numbers and events that tell the story of your program.

2

Add API calls to the code

Place calls that start and end spans, record metrics and attach details at those points.

3

The SDK processes the data

The configured library batches and prepares the telemetry for sending.

4

The data reaches a backend

An exporter sends it to a Collector or monitoring tool where people can search and chart it.

!
Common Misconception

Manual does not mean writing everything from scratch or abandoning automation. In practice, teams combine both: automatic instrumentation for the common parts and manual instrumentation for the parts that are special to their business.

4The Three Styles of Instrumentation

Manual instrumentation is one of several ways to produce telemetry, and each has its place.

There are three broad styles of instrumentation in the OpenTelemetry world. Understanding all three makes it clear when manual work is worth the effort.

Style 1

Zero-code Automatic

An agent or tool attaches to the running program and instruments well-known frameworks and libraries without any code changes. Fast to adopt, but generic.

Style 2

Instrumentation Libraries

Ready-made packages that wrap popular tools, such as web frameworks and database drivers. You add and configure them, but they emit telemetry for you.

Style 3

Manual Instrumentation

You write the API calls yourself, exactly where you want them. The most work, and the most control and meaning.

QuestionZero-code automaticInstrumentation librariesManual
Effort to startVery lowLow to mediumHighest
Code changes neededNoneSmall setup changesCalls added across your code
Knows your business logic?NoNoYes
Control over detailLimitedModerateComplete
Best forFast first visibilityStandard frameworks and driversCustom logic and business events
Simple Analogy

Think of three ways to record a family trip. Automatic is a dashcam that films everything on the road without your effort. Libraries are like using a travel app that logs your flights and hotels for you. Manual is writing your own journal with the moments that mattered to you, like a conversation with a stranger that no camera could understand.

5Why Automatic Is Not Enough

Automatic tools see the doors of your program, but not the rooms inside.

Automatic instrumentation is a wonderful starting point. It can tell you that a web request arrived, that it took two seconds, that it called a database and that the database took one second. But look at what it cannot see. It does not know that inside those two seconds your code calculated a discount, checked a loyalty tier, ran a fraud rule and chose a shipping provider. To the automatic tool, all of this is a black box between the incoming request and the outgoing call.

Automatic tools also do not know what is important to your business. They do not know that a certain customer type matters, that a certain feature flag is being tested, or that a certain step is the one the finance team cares about. Only you know that, and manual instrumentation is how you tell OpenTelemetry about it.

flowchart TD
  A["Incoming request span: created automatically"] --> B["Your business logic: invisible without manual work"]
  B --> C["Database call span: created automatically"]
  B --> M1["Manual span: calculate discount"]
  B --> M2["Manual span: run fraud rule"]
  B --> M3["Manual span: choose shipping provider"]
        
FIG 1 — Automatic spans see the edges, manual spans reveal the middle
i
Key Insight

Automatic instrumentation answers where the request went. Manual instrumentation answers what your code decided and why it took the time it did.

6When Should You Instrument Manually?

Manual effort pays off in a few clear situations.

Important business steps

Calculating a price, approving a loan, matching a driver to a rider. These steps are where the value of your product lives, and they are invisible to automatic tools.

Custom or in-house frameworks

If your company built its own messaging or workflow library, no ready-made instrumentation exists for it. Manual calls are the only way to see inside.

Business metrics

Counting orders placed, payments declined or items added to carts. These numbers connect engineering health to company results.

Rich context on spans

Attaching details such as the customer tier, the region or the experiment name to a span, so that engineers can filter and compare traces later.

Unsupported languages or libraries

When no automatic tool exists for your language, framework or version, manual instrumentation is the dependable fallback.

Library authors

People who write shared libraries can add manual instrumentation using only the thin API, so that every application using the library gains telemetry without being forced to pick a vendor.

!
Watch Out

Do not rush to instrument everything by hand on day one. Start with automatic tools to get a broad picture, then add manual instrumentation where that picture has gaps.

7The Setup Before You Instrument

A little one-time configuration is needed before any manual call does something useful.

The API alone only creates empty promises. For telemetry to actually leave the program, the application must set up the SDK once, usually when it starts. This setup is normally done in one central place, and individual pieces of code do not need to repeat it.

1

Describe the resource

Give the application a clear service name, version and environment, so every signal says who sent it.

2

Create the providers

Set up a tracer provider for traces, a meter provider for metrics and a logger provider for logs.

3

Choose processors and exporters

Decide how telemetry is batched and where it is sent, usually to a Collector using the standard protocol.

4

Register them globally

Make the providers available to the whole program so that API calls everywhere find them automatically.

5

Shut down cleanly at exit

Flush pending data when the program ends, so the last batch of telemetry is not lost.

Simple Analogy

Setting up the SDK is like plugging in the power station and connecting the wires before you start installing lamps. Once the wiring is in place, every lamp you add anywhere in the house simply works when you flip the switch.

i
Good to Know

If the SDK is not configured, manual calls still run without errors, but they quietly do nothing. If you see no data, check the setup first.

8Manual Tracing: Creating Spans

A span is one timed step, and manual tracing is the art of choosing which steps get one.

A trace is the story of one request, and a span is one chapter of that story. Each span has a name, a start time, an end time and a set of details. To create spans by hand, your code first asks the tracer provider for a tracer, which is named after the component or library that uses it. It then starts a span at the beginning of an operation and ends it when the operation finishes.

sequenceDiagram
  participant Code as Your Code
  participant T as Tracer
  participant S as Span
  Code->>T: Start span named calculate discount
  T-->>Code: Span, now the current span
  Code->>S: Add attributes and events
  Code->>Code: Do the work
  Code->>S: Set status if it failed
  Code->>S: End span
        
FIG 2 — The life of a manually created span

The parts of a span you control

Part 1

Name

A short, stable description of the operation, such as calculate discount. It names the kind of work, not one specific customer.

Part 2

Kind

Whether the span is internal work, a server handling a call, a client making a call, or a producer or consumer of messages.

Part 3

Attributes

Named details about this operation, such as the customer tier or the number of items. They make traces searchable.

Part 4

Events

Time-stamped notes inside the span, such as cache miss or retry started. Small markers along the timeline.

Part 5

Status

Whether the operation succeeded, failed or was left unset. A failed status makes errors easy to find.

Part 6

Links

Pointers to related spans in other traces, useful for batch jobs that process work from many requests.

Simple Analogy

A span is like a stopwatch lap in a race. You press start when a runner begins a section and stop when the section ends. You can also write notes on the lap card: the weather, how the runner felt, a stumble at the halfway point.

9Parents, Children and the Current Span

Spans form a tree, and the library keeps track of where you are in it.

Spans are arranged in a family tree. The first span of a request is the root. Every span started while another span is active becomes its child. This nesting shows how one operation contains others, and it lets viewing tools draw the familiar waterfall picture of a request.

OpenTelemetry keeps a hidden record of the current span in what it calls the context. When you start a new span and make it current, any span you start afterward becomes its child automatically. When you end your span, the previous span becomes current again. As a result, you rarely need to pass parent information around by hand inside one program.

flowchart TD
  R["Root: handle checkout request"] --> A["Child: validate cart"]
  R --> B["Child: calculate discount"]
  B --> B1["Grandchild: load loyalty tier"]
  B --> B2["Grandchild: apply coupon rules"]
  R --> C["Child: charge payment"]
        
FIG 3 — Nested spans show what contains what
!
Common Mistake

Starting a span but forgetting to make it current, so that later spans do not become its children and the trace looks flat or disconnected. Use the library’s helper that starts a span and makes it current in one step.

i
Practical Tip

In languages with threads or asynchronous work, the context must travel with the work. Use the library’s support for carrying context across threads, tasks and callbacks, or the child spans will lose their parent.

10Attributes: Making Spans Searchable

Attributes are the labels that turn a timeline into something you can question.

A span with only a name and a duration tells you how long something took. A span with attributes tells you which kind of case it was. Attributes are small named values, such as the customer tier, the payment method, the region or the number of items in a cart. With them, an engineer can ask questions like show me slow checkouts for premium customers in one region.

Good Attributes

  • Customer tier, plan or segment
  • Payment method or shipping option
  • Region, environment or feature flag name
  • Counts such as items in a cart or records in a batch
  • Names of rules or strategies that were chosen

Risky Attributes

  • Passwords, tokens and secret keys
  • Full card numbers or government identifiers
  • Whole request or response bodies
  • Personal details such as email addresses and home addresses
  • Huge text blobs that bloat every span

Follow the semantic conventions

OpenTelemetry publishes semantic conventions, which are agreed names and meanings for common attributes. For example, there are standard names for HTTP methods, database systems and messaging destinations. Using the shared names, rather than inventing your own, means that dashboards and tools built by others work with your data with no extra effort. For your own business concepts, create clear names and keep them consistent across teams, perhaps with a company prefix.

Simple Analogy

Attributes are like the labeled tabs on a filing cabinet. A folder without a tab is hard to find. A folder with a tab saying region, tier or month can be located in seconds, and everyone agrees what the tabs mean.

!
Privacy Warning

Span attributes are stored and searchable by many people. Never attach secrets or sensitive personal data, because once exported to a vendor they are very hard to remove.

11Recording Errors and Status

A trace that cannot show failures is only half useful.

When something goes wrong inside an operation, the span should say so. Manual instrumentation lets you do two things. You can set the span’s status to error, which flags the whole step as failed so that tools can highlight it and count it. And you can record the exception itself as an event on the span, which captures the error type, the message and often the place in the code where it happened.

1

Catch the failure

The code notices that the operation could not complete, for example a payment was declined.

2

Record the exception

Attach the error details to the span as an event so engineers can read exactly what went wrong.

3

Mark the status as error

Flag the span as failed with a short description, so error-rate charts and trace searches work.

4

End the span anyway

Make sure the span is closed even on the failure path, so its timing is recorded.

i
Good to Know

Leave the status unset for ordinary success. Only mark real failures as errors. An expected outcome, such as a user entering a wrong password, is often better recorded as a normal result with an attribute.

!
Common Mistake

Forgetting to end a span when an error occurs. A span that is never ended is never sent, so the very failure you wanted to see disappears from your traces.

12Manual Metrics: Counting What Matters

Spans tell individual stories, and metrics tell the trend.

Manual instrumentation is not only about traces. You can also create instruments that record numbers over time. You ask the meter provider for a meter, then create the instruments you need, once, when the program starts, and reuse them everywhere. Each time something happens, your code records a value.

InstrumentWhat it recordsBusiness example
CounterA total that only growsOrders placed, payments declined
UpDownCounterA balance that rises and fallsItems in a queue, active sessions
HistogramA spread of valuesTime taken to calculate a quote, basket size
GaugeA current readingTemperature of a sensor, size of a cache
Simple Analogy

If spans are individual photographs of customer visits, metrics are the sales totals on the shop’s whiteboard. The photographs show detail, and the whiteboard shows the trend at a glance.

Metrics need careful attributes too

Each unique combination of attribute values creates a separate time series, which costs memory and money. Use attributes with a small, known set of values, such as payment method or region. Never use values that are different for every event, such as user identifiers or request identifiers. Those belong on spans or logs, not on metrics.

!
Cost Warning

A single careless metric attribute can multiply your monitoring bill many times over. If a value is unique per event, keep it off your metrics.

13Manual Logs: Adding Context to Messages

Logs join the story when they carry the identity of the request.

For logs, most teams do not call OpenTelemetry directly. They keep using the logging library they already know, and connect it to OpenTelemetry through a bridge. What manual instrumentation adds here is context: when a log is written inside an active span, the bridge stamps the log record with that span’s Trace ID and Span ID. Later, an engineer can jump from a slow span straight to the logs written during it.

You can also add structured attributes to your own log messages, such as the order number or the rule that fired, so that logs are searchable by detail rather than only by text. Keep the same care about secrets that applies to spans.

i
Big Win

When logs, spans and metrics all share the same context and the same resource description, one investigation can move smoothly between all three signals.

14Crossing Boundaries: Context Propagation

Spans in different services only join one trace if the context travels with the request.

Inside one program, the library tracks the current context for you. But when a request leaves your program and enters another one over the network, the memory is not shared. Something must carry the trace identity across the gap. This is called context propagation, and it works by writing the trace information into a header, a labeled piece of extra data that rides along with the call. The receiving program reads the header and continues the same trace.

sequenceDiagram
  participant A as Service A
  participant B as Service B
  Note over A: Manual span: prepare order
  A->>A: Inject trace context into outgoing headers
  A->>B: Call with tracing header
  B->>B: Extract context from incoming headers
  Note over B: Manual span: reserve stock, child of A's span
        
FIG 4 — Inject on the way out, extract on the way in

Automatic tools usually handle this for common web and messaging libraries. But when you use your own protocol, a custom queue or an unusual transport, you must perform the two steps manually: inject the context into the outgoing message, and extract it from the incoming message. Without both steps, the trace breaks into disconnected pieces.

Simple Analogy

Propagation is like passing a relay baton. The runner who finishes must hand over the baton, and the next runner must take hold of it. If either step is skipped, the next runner starts a brand-new race, and the story of the first one is lost.

!
Watch Out

Message queues are the classic breaking point. If the message metadata does not carry the tracing information, the consumer starts a new trace, and the link between producer and consumer is lost.

15Mixing Automatic and Manual Together

The best setups use both, and they fit together naturally.

Because both styles use the same API and the same context, they cooperate without special effort. Automatic instrumentation creates the outer spans, such as the incoming web request and the outgoing database call. Your manual spans, started inside your code while the automatic span is current, become children of it automatically. The result is one complete tree, with the framework’s view at the edges and your business view in the middle.

flowchart TD
  A["Automatic: HTTP server span"] --> M1["Manual: validate cart"]
  A --> M2["Manual: calculate discount"]
  M2 --> D["Automatic: database client span"]
  A --> M3["Manual: choose shipping provider"]
  M3 --> H["Automatic: outgoing HTTP client span"]
        
FIG 5 — Automatic and manual spans woven into one trace
1

Start with automatic

Switch on automatic instrumentation to see the broad shape of your system quickly.

2

Find the gaps

Look at real traces and notice where long, unexplained stretches appear inside your own code.

3

Add manual spans there

Instrument the important operations inside those gaps, and attach meaningful attributes.

4

Add business metrics

Create counters and histograms for the numbers the business cares about.

5

Review and refine

Remove noise, fix names and improve attributes as you learn what engineers actually use.

i
Practical Tip

Enrich the automatic span too. Your code can fetch the current span and add a business attribute to it, such as the customer tier, without creating any new span at all.

16How Much Should You Instrument?

More is not always better. The art lies in choosing the right amount.

New adopters often swing between two extremes. Some instrument nothing and remain blind. Others wrap every function in a span and drown in noise and cost. The wise path lies in the middle: instrument operations that are meaningful, that could be slow, that could fail, or that cross a boundary.

Worth a Span

  • Calls to other services, databases and queues
  • Meaningful business steps such as pricing or approval
  • Operations that could be slow or could fail
  • Work handed to background threads or jobs
  • Steps where you often ask what took the time

Not Worth a Span

  • Tiny helper functions that run in microseconds
  • Every iteration of a tight loop
  • Simple getters and setters
  • Steps that never fail and are never slow
  • Duplicates of spans that automatic tools already create
Simple Analogy

A travel diary that records every footstep would be unreadable. A diary that records only the airport and the hotel would miss the adventure. The best diary notes the memorable moments: the border crossing, the wrong turn, the lucky meal.

!
Performance Note

Creating a span costs a little time and memory. A span inside a loop that runs a million times per second can slow the program and flood the pipeline. For repeated work, use a metric or a single span around the whole loop with a count attribute.

17Naming and Organizing Your Instrumentation

Good names are a gift to everyone who reads traces later.

Names are the first thing a person sees in a trace, so they deserve care. A good span name is short, describes the kind of work, and stays the same across requests. It names the operation, not the particular customer or order. Details that change from request to request belong in attributes.

Weak span nameStrong span nameWhy
process order 84721process orderThe identifier belongs in an attribute, not in the name
step 3calculate discountNames should say what the work is
doStuffreserve inventoryVague names tell the reader nothing
customer alice checkoutcheckoutPersonal data and variable parts do not belong in names

Name your tracer and meter well

The tracer and meter are named after the component or library that owns them, and often carry a version. This name appears as the instrumentation scope, which lets engineers separate your code’s telemetry from that of frameworks and drivers. Create one tracer and one meter per component, and reuse them rather than recreating them for every call.

i
Good to Know

Span names with high variety create trouble for tools that group traces by name. Keep the set of names small and predictable.

18Design Patterns and Anti-patterns

Good habits and bad habits repeat across teams.

Patterns that work

A helpful pattern is the wrapper helper: a small function that starts a span, runs your work, records errors and always ends the span, so developers cannot forget the cleanup. Another is instrumenting at boundaries, where your code meets other systems, since that is where time and failures hide. A third is start small and grow, adding spans and metrics in response to real questions asked during real incidents.

ANTI-PATTERN-01 Avoid
Problem

Starting a span and ending it only on the success path.

Why It’s Harmful

When an error occurs, the span is never ended and never exported, so failures vanish from traces and memory can leak.

Correct Approach

End the span in a place that always runs, such as a final cleanup step, and record the error before ending.

ANTI-PATTERN-02 Avoid
Problem

Putting changing values such as order numbers or user names into span names.

Why It’s Harmful

Every request creates a unique name, which breaks grouping, makes charts useless and increases storage cost.

Correct Approach

Keep names stable and move variable details into attributes.

ANTI-PATTERN-03 Avoid
Problem

Creating a span for every tiny function and every loop iteration.

Why It’s Harmful

It slows the application, floods the pipeline and hides the meaningful steps in a forest of noise.

Correct Approach

Instrument boundaries and meaningful business steps, and use metrics for high-frequency counting.

ANTI-PATTERN-04 Avoid
Problem

Attaching secrets, personal data or whole request bodies as attributes.

Why It’s Harmful

The data spreads into searchable storage, vendors and archives, creating legal and security risk that is hard to undo.

Correct Approach

Attach only safe, useful details, and mask sensitive fields in the Collector as a second line of defense.

ANTI-PATTERN-05 Avoid
Problem

Libraries that install and configure their own SDK or exporter.

Why It’s Harmful

It forces a destination on every application that uses the library and can cause duplicate or conflicting configuration.

Correct Approach

Libraries should depend only on the thin API, and leave SDK setup to the application owner.

19Best Practices and Common Mistakes

A short checklist that saves hours of pain later.

Do

Set Up the SDK Once

Configure resource, providers and exporters in one central place at startup, and shut down cleanly on exit.

Do

Always End Spans

Close every span on every path, including errors, timeouts and early returns.

Do

Use Semantic Conventions

Prefer shared attribute names so that tools and dashboards work out of the box.

Do

Instrument Boundaries

Focus on calls to other systems and on important business steps.

Do

Create Instruments Once

Build tracers, meters and instruments at startup and reuse them rather than recreating them per request.

Don’t

Log Secrets in Attributes

Keep passwords, tokens and personal data out of telemetry entirely.

Don’t

Use Unbounded Metric Labels

User identifiers and request identifiers on metrics explode your series count and your bill.

Don’t

Duplicate Automatic Spans

Check what automatic tools already create before adding your own, to avoid doubled steps in traces.

i
Debugging Tip

If your manual spans do not appear, check the basics: is the SDK configured, is a sampler dropping the trace, is the exporter reaching the Collector, and did the program live long enough to flush its last batch?

20Advantages and Trade-offs

Every design choice has a price, and manual instrumentation is no exception.

Advantages

  • Captures exactly the business logic that matters to you
  • Complete control over names, attributes and detail
  • Fills the gaps that automatic tools cannot see
  • Works for custom frameworks and unsupported languages
  • Enables business metrics tied to company outcomes
  • Stays vendor neutral because it uses only the standard API

Disadvantages / Trade-offs

  • Takes developer time to write and maintain
  • Inconsistent naming across teams if no standard exists
  • Easy to forget to end spans or to leak sensitive data
  • Too much instrumentation adds overhead and cost
  • Code changes require a redeploy, unlike zero-code tools

Balancing effort and insight

Each manual call you add costs a little effort now and a little maintenance later, and it returns insight whenever someone investigates a problem. The best returns come from the few places where your code makes important decisions or talks to the outside world. Spread your effort there, lean on automatic tools elsewhere, and revisit your choices as real incidents teach you which questions matter.

21Real-World Examples

Seeing how teams use manual instrumentation makes the ideas concrete.

An online retailer with a slow checkout

Automatic traces show that checkout takes four seconds but cannot explain why. The team adds manual spans around discount calculation, fraud rules and shipping selection. The new spans reveal that the fraud rules call an external service that is slow for one region.

A bank measuring approval steps

The bank adds a span for each stage of loan approval and attaches the loan type as an attribute. A histogram records the time of each stage. Managers see which stage delays customers the most, and engineers see traces of the slowest cases.

A company with an in-house messaging library

No ready-made instrumentation exists for the library, so the platform team wraps its send and receive functions once. They inject context when sending and extract it on receipt. Every team that uses the library now gets connected traces across queues for free.

A subscription service tracking business events

A counter records signups and cancellations with a plan attribute. When cancellations jump for one plan after a release, the team spots it within minutes and rolls back a faulty change.

A shared library author

The author of a popular payment library adds spans using only the thin API. Applications that install an SDK see rich payment traces. Applications that do not, pay almost no cost at all.

A team running an experiment

Engineers add the experiment name as an attribute on the current span. Later, they compare the latency and error rate of traces from the new and old variants side by side to decide which one to keep.

“Automatic instrumentation tells you what your framework did. Manual instrumentation tells you what your business decided.”

22Frequently Asked Questions

Q1What is manual instrumentation in one sentence?

It is writing OpenTelemetry API calls by hand in your own code, so that your program creates the spans, metrics and logs you choose, with the details you care about.

Q2How is it different from automatic instrumentation?

Automatic instrumentation is added by a tool or agent without code changes and covers well-known frameworks. Manual instrumentation is written by you and covers your own logic and business events.

Q3Do I need to choose between them?

No. They share the same API and context, so they combine naturally. Most teams start with automatic and add manual instrumentation to fill the gaps.

Q4What is the difference between the API and the SDK?

The API is the thin set of calls your code uses to create telemetry. The SDK is the engine that processes and exports it. Libraries should depend only on the API, and applications install the SDK.

Q5Why do my manual spans not show up?

Common causes are an unconfigured SDK, a sampler that dropped the trace, spans that were never ended, an exporter that cannot reach the Collector, or a program that exited before flushing.

Q6What should I put in a span name?

A short, stable description of the kind of work, such as calculate discount. Put changing details such as identifiers into attributes instead.

Q7How do I connect spans across services?

Through context propagation. The sender injects the trace context into the outgoing message and the receiver extracts it, so the spans join the same trace.

Q8Should I wrap every function in a span?

No. Instrument calls to other systems, meaningful business steps and operations that may be slow or may fail. Too many spans add cost and noise.

Q9How do I record that an operation failed?

Record the exception on the span and set its status to error, then make sure the span is ended on that path too.

Q10Can I add business details to an automatic span?

Yes. Fetch the current span and add attributes to it, such as the customer tier, without creating a new span.

Q11Does manual instrumentation slow my application?

Slightly. Each span costs a little time and memory, which is negligible when placed sensibly and noticeable when placed inside very hot loops.

Q12Is manual instrumentation tied to a specific vendor?

No. It uses the standard OpenTelemetry API, so you can change the exporter or backend without touching your instrumentation code.

Q13Where should I start?

Turn on automatic instrumentation, look at real traces, find the unexplained gaps in your own code, and add manual spans and a few business metrics there.

23Summary and Key Takeaways

We began with a delivery van whose factory gauges work on their own, while the sensors for parcels and stops must be fitted by hand. Manual instrumentation in OpenTelemetry is that hand-fitted equipment. You use the thin API to create spans around meaningful operations, attach attributes that make traces searchable, record errors, create metrics for business numbers, and carry context across boundaries so that traces stay whole. The SDK, configured once by the application owner, turns those calls into real telemetry. Combined with automatic instrumentation, it gives you both the broad view of your framework and the precise view of your own decisions.

Key Takeaways

  • Manual instrumentation means writing API calls yourself — you decide which operations, numbers and events your program reports, and which details travel with them.
  • It fills the gaps automatic tools leave — automatic instrumentation sees the edges of your program, while manual spans reveal the business logic in the middle.
  • The API and SDK are separate — code uses the thin API, and the application owner configures the SDK once at startup, which keeps libraries vendor neutral.
  • Spans need care — use short stable names, meaningful attributes following the semantic conventions, record errors, and always end every span on every path.
  • Metrics and logs join in — create instruments once for business numbers, keep metric attributes bounded, and let logs carry trace context through a bridge.
  • Propagate context across boundaries — inject on the way out and extract on the way in, or traces break into disconnected pieces.
  • Instrument the right amount — focus on boundaries and important business steps, keep secrets out of attributes, and combine automatic and manual styles for the best result.