Observability Engineering second edition out now! 27 net-new chapters written for today's observability challenges.Get your copy

The Engineer’s Guide to Sampling in the Age of AI

The Engineer’s Guide to Sampling in the Age of AI

Observability is a holistic approach to understanding the internal workings of our systems. Unlike traditional monitoring, which depends on predefined thresholds and known behaviors, observability allows teams to diagnose unexpected issues and learn patterns in system behavior anytime. Observability depends on high-quality telemetry, making effective data volume management an important element of success.

Without proper management, the sheer volumes of logs, metrics, and traces can overwhelm storage and processing systems and make it difficult to extract meaningful insights. By implementing strategies like sampling, engineers can optimize their telemetry data by retaining the most valuable information while reducing noise and costs. AI is also beginning to change how sampling decisions get made in the first place toward approaches that can adapt to what your system is actually doing. In this guide, we’ll explore the fundamentals of sampling, equipping you with the knowledge to manage your data volumes efficiently without sacrificing visibility into your systems.

What is sampling?

Sampling is a technique for selecting a subset of data while setting aside the rest. To illustrate this concept, imagine a factory production line that manufactures marbles. Instead of inspecting every marble for defects, the factory examines a random subset to estimate the overall defect rate. This sample serves as a reliable representation of the entire batch of marbles and can be used to understand the overall quality of their marbles.

Selectively retaining a representative subset of telemetry data allows engineers to reduce storage and processing costs while preserving key insights for analysis. In observability, sampling is used on telemetry data, like traces, to capture key insights without storing every trace for every request. The sampled traces still provide valuable visibility into system behavior in the context of the request event.

Sampling can be categorized by two methods: head-based and tail-based, which we’ll examine more closely.

Head sampling

Head-based sampling uses predefined rules to determine whether to retain a piece of data. These rules do not rely on the content of the data itself. For example, a head-based sample rule could retain data at a fixed rate, such as every nth interval. Users should not use head-based sampling in environments with low error rates because the head-based sample selection might not yield accurate insights. Head-based sampling is particularly useful for high-volume services where sampling at the source can reduce data overload.

Use head-based sampling when:

  • Immediate decisions are needed to limit data ingestion.
  • Operating in a high-throughput environment where cost constraints make it impractical to retain all traces.
  • A low-latency decision-making process is required.

Tradeoffs in head-based sampling:

  • Pros: Simple to implement, computationally efficient.
  • Cons: May miss critical events (e.g., errors) as selection is random and outcome-based.

Tail sampling

Tail-based sampling uses predefined rules and the content of the data to determine whether to retain a piece of data. This approach enables intelligent retention of data points. For example, we could use tail-based sampling rules to keep all error traces and sample successful traces at a lower rate. Tail-based sampling works well in complex distributed systems because it correlates data across services to provide a holistic view of issues. It would not be ideal for situations where low-latency decision-making is needed, since tail-based sampling can require additional processing and slight delays in sampling decisions.

Use tail-based sampling when:

  • Data needs to be captured based on their execution outcome.
  • Debugging complex distributed systems where issues become apparent after a request has been completed.
  • Data would otherwise be missed with head-based sampling.

Tradeoffs in tail-based sampling:

  • Pros: Captures high-value data and is more effective for complex systems.
  • Cons: Higher computational and memory overhead, and can impact real-time monitoring/alerting because of potential delays in data processing.

Organizations with heavy traffic loads can mix head and tail sampling to balance cost and visibility. While head-based sampling helps control ingestion volume at the source, a tail-based approach ensures that key insights aren’t lost. This hybrid strategy provides engineers with a more reliable view of system health, ultimately improving incident response and system performance.

The advantages of tail-based sampling in Honeycomb Refinery

Honeycomb Refinery is a tail-based sampling proxy used to improve the quality of traces while minimizing storage and processing costs. Refinery ensures that important data, such as errors and anomalies, is retained, while less critical data is sampled at lower rates. People often overestimate how much they really need to keep, so using a tool like Refinery is an effective approach to managing data volumes for observability.

Honeycomb chose tail-based sampling for Refinery to avoid these pitfalls. By analyzing traces holistically before making sampling decisions, Refinery ensures that error traces are fully retained while only a subset of successful requests are kept. Plus, Honeycomb takes Refinery’s reported sampling rates and extrapolates them to maintain accurate proportions into your query results.

As AI-assisted investigation becomes more common—whether through Canvas or your own agentic tooling—the value of Refinery’s holistic approach compounds. An agent trying to explain a latency spike needs the full trace, with context intact. Refinery’s bias toward retaining complete, meaningful traces means the data those agents need is more likely to be there when they go looking.

When do you need sampling?

Not every system needs sampling! If your data volume is manageable and your storage budget allows, sampling may not be necessary. But here are some good guidelines on when to sample:

  • High-throughput systems: When your system generates terabytes of telemetry data daily.
  • Cost constraints: To reduce storage and processing expenses.
  • Improved data quality: When you need data with a higher concentration of specific types of events, such as errors or performance bottlenecks.
  • Distributed architectures: To avoid excessive data duplication across services.

Other considerations for managing data volumes

Cost savings

Sampling helps control observability costs by reducing the volume of data ingested, stored, and processed. Sampling is just one tool for managing observability costs. Other strategies include tuning instrumentation to stop sending needless or noisy data and filtering low-value logs.

Archival backup

Low-cost archival storage can provide a “backup plan” for your data volume management strategies, ensuring discarded data isn’t lost forever. Leveraging an efficient rehydration or query retrieval system, engineers can pull in archived data on demand. Here are some best practices for archiving data:

  • Tag and index archived data properly for effective retrieval when needed.
  • Batch data to optimize file size, balancing per-file storage cost with retrieval granularity.
  • Define a clear retention policy to balance data storage costs with accessibility.
  • Use query-based rehydration to pull only the relevant slices of data, rather than restoring full archives of data.

Archival data retrieval makes it possible for you to reduce data volume while still effectively addressing compliance, incidents, anomalies, and analytical requirements.

Reducing noise

By dropping telemetry data you’re unsure you’ll need, sampling brings to attention the data that matters most, making it easier to spot, understand, and fix problems. A common misconception about sampling is that it may compromise metric accuracy, but by tracking sample rates, observability tools can adjust metrics to reflect the entire dataset, leading to acceptable metrics that reflect your system’s performance.

AI-assisted sampling decisions

Standard rules across the board may not clearly capture the best fidelity of traffic that you need for your most critical SLOs. A general rule identifying high-latency spans at 1000ms for most of your traffic is good, but for your /checkout API endpoint, you should really have a rule that is tailored to the 200ms limit you care about.

AI can help you maintain rules that are targeted for your most critical traffic, and keep track of a much larger ruleset than we generally cared to keep as humans, allowing you to shift your sampling as your business needs and pains shift.

One useful data point: AI agents doing automated investigation work tend to prefer raw, high-cardinality telemetry over pre-aggregated data the majority of the time. If you’re building toward any kind of AI-assisted incident response or root cause analysis, that’s worth factoring into your retention strategy now.

Configuring sampling logic and rules

An ideal sampling rate depends on your system and your requirements. Here is how you can determine the right rate for different scenarios:

High-throughput, cost-constrained systems

  • Sampling rate: Low (e.g., 1–10%).
  • Why? Retaining every piece of data is too expensive, so random head-based sampling can help reduce ingestion costs while still providing real-time insights.

Debugging and incident response

  • Sampling rate: High for errors and anomalies (e.g., 50-100%), lower for normal traffic (e.g., 1-10%).
  • Why? Tail-based sampling can capture the details of failures or system anomalies while ignoring routine requests that are not relevant to reduce noise and costs.

Compliance and audit requirements

  • Sampling rate: 100% for specific workflows or regulated transactions, or if using an archive, sample with other data.
  • Why? Some industries require complete trace logs for security, compliance, or legal reasons, making selecting full retention necessary. If you can’t retrieve this data from an archive, you’ll need to keep all traces.

User experience and performance monitoring

  • Sampling rate: Moderate (e.g., 10-50%) with priority on slow or failed requests.
  • Why? Ensures meaningful insights into performance issues while keeping storage costs manageable.

General rules of thumb

  • Start with 1-10% for normal traffic in cost-sensitive situations.
  • Increase sampling for errors, anomalies, and critical transactions (50-100%).
  • Use dynamic or AI-driven sampling when system behavior is unpredictable.
  • Always ensure you can rehydrate old data if deeper analysis is anticipated.

How to get started with sampling

If you’re looking to kickstart your observability journey, Honeycomb Telemetry Pipeline equips Enterprise teams with powerful tools to make sampling safer and observability data easier to manage. Honeycomb Telemetry Pipeline helps you control costs while retaining high-value data across any observability use case. From the Honeycomb UI, you can even rehydrate full-fidelity logs or traces on demand, enhancing your existing Honeycomb data without disruption.

  • 1. Set up the Honeycomb Telemetry Pipeline: Create a pipeline in the Honeycomb UI and follow the steps to install the underlying architecture (OTel Collectors and Refinery) in your infrastructure. The default configuration allows you to start sending your data to Honeycomb.
  • 2. Choose a sampling strategy: Define your sampling rules in the Pipeline Builder UI, starting with a template and adding configuration using drag-and-drop components based on common use cases. Honeycomb Telemetry Pipeline supports multiple sampling techniques, including basic head-based sampling as well as Refinery’s dynamic holistic tail-based sampling.
  • 3. Back up to an archive: Use a built-in UI component to route a copy of your data to archival storage in your own S3 bucket. Batching configuration for optimal file size is built-in automatically. You can later access this data on demand for full analysis, directly from the Honeycomb query engine.
  • 4. Monitor and adjust your strategy: You can use Honeycomb’s dashboards and analytics to review trace retention and cost savings. If needed, adjust sampling rates and rules to ensure enough data is available for your use cases.

Tools like Canvas can accelerate this process considerably. Rather than manually reviewing dashboards to spot coverage gaps, you can ask Canvas to investigate whether your current sampling strategy is dropping data from services that are behaving unusually—and get a reasoned answer back in seconds instead of spending an hour building queries to check. Think of it as a faster feedback loop on your sampling configuration, not just on your system behavior.

Not sure about any of these steps? Honeycomb offers professional services to help teams design and fine-tune their data strategy.

Conclusion

Sampling is a powerful tool for managing data volumes. Implementing strategies like head-based and tail-based sampling can reduce costs, improve focus, and enhance the quality of your telemetry data. Tools like Honeycomb Refinery make it easy to adopt sampling and data management strategies so that your observability stack remains efficient and effective.

Optimize your observability today with dynamic sampling and Honeycomb Refinery.

Ready to get started?