Best Practices & Process

Cutting Observability Costs: Sampling & Telemetry Strategies

Master observability cost optimization telemetry with sampling, retention policies, and cardinality controls. Cut costs 40–60% while maintaining visibility.

Observability budgets are out of control. Most teams don't realize they're collecting the same errors 500 times, tracing every database query regardless of impact, and storing debug data long past its useful life. The result: 96% of organizations are now actively managing observability cost optimization telemetry through sampling, retention policies, and cardinality discipline. You don't cut costs by seeing less—you cut costs by being intentional about what you collect and how long you keep it.

Done right, these strategies reduce observability spending by 40–60% while actually improving your signal-to-noise ratio. You'll catch more bugs, alert on what matters, and spend less. This post covers the mechanics: where sampling lives, how retention tiers work, why cardinality explodes costs, and how to implement each without blind spots.

Head vs. Tail Sampling: Where the Cost Cuts Happen

Sampling reduces volume by capturing only a fraction of events. The two approaches differ in when and where you decide what to keep.

Head sampling happens at the source—your application. Before you send a trace to LightTrace, your SDK decides: "Keep this one, drop that one." It's cheap to implement but dumb; you might discard a rare error because it happened to fall outside your sample window.

// Sentry SDK: head sampling at 10%
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: 'https://<key>@light-trace.robomiri.com/1',
  tracesSampleRate: 0.1, // Capture 10% of all transactions
});

Tail sampling is smarter: you send everything to LightTrace temporarily, then apply rules after you've seen the full trace. A tail-sampling rule might say: "keep all errors, keep all transactions slower than 500ms, keep 1% of successful fast traces." This way you never miss the events that matter while cutting the noise.

Most teams start with head sampling (it's built into every Sentry SDK) and gradually move to tail sampling as they grow. The key insight: pair head sampling with error-based rules so you capture 100% of errors and 10% of successful transactions.

// Sentry SDK: smart sampling by outcome
Sentry.init({
  dsn: 'https://<key>@light-trace.robomiri.com/1',
  tracesSampler: (context) => {
    // Always keep errors
    if (context.transactionContext.op === 'http.server') {
      return context.transactionContext.status !== 'ok' ? 1.0 : 0.05;
    }
    return 0.05; // 5% of database queries, background jobs, etc.
  },
});

Start with 50% sampling and measure impact on your dashboards for two weeks. If you miss critical signals, raise it to 75% or 100%. Once you're confident, drop to 10% for non-error traffic. You can always adjust—sampling rules are runtime knobs, not deploys.

Data Retention: Align Storage Duration to Business Value

Not all telemetry has the same value forever. An error you're triaging today is critical; one you resolved six months ago is an archive entry. Smart retention cuts storage costs while keeping what matters.

Implement a tiered retention model:

  • Unresolved errors: 90 days (full fidelity, every detail matters)
  • Resolved errors: 30 days (historical reference, reduced cardinality)
  • Slow transactions: 60 days (performance debugging window)
  • Successful transactions: 7 days (snapshot for baseline only)

LightTrace lets you set retention per event type. The business case is straightforward: you don't need six months of "successful API call" storage, but you do need to reference a production incident from four weeks ago.

Connect retention to your error budgets and SLOs. If your SLO commits to 99% uptime, keep detailed traces from incidents that threatened it, then archive the peacetime baseline. You've already debugged it; you just need the log for compliance.

Move old data to cold storage (S3, GCS) instead of deleting it. You'll stop paying hot-storage costs but keep the incident record for post-mortems and audits.

Cardinality: The Silent Cost Multiplier

Cardinality is the number of unique values for a tag or dimension. Tag every request with user_id and you have cardinality equal to your user count—potentially millions. Tag by request_id and it's billions. High cardinality explodes storage and query costs.

The rule: a tag should have <1,000 unique values in your system. Violations:

  • user_id as a tag (move to context)
  • request_id, trace_id, timestamp (these should be fields, not tags)
  • Unbounded enums like HTTP headers or query parameters (pick only the common ones)
// Sentry SDK: cardinality discipline
import * as Sentry from '@sentry/node';

// BAD: high cardinality
Sentry.setTag('user_id', userId); // millions of values
Sentry.setTag('request_id', requestId); // unique per request
Sentry.setTag('timestamp', Date.now()); // every second is different

// GOOD: context instead of tags
Sentry.setContext('user', { id: userId, email: userEmail });
Sentry.setContext('request', { id: requestId, path: '/api/users' });

// GOOD: bounded tags only
Sentry.setTag('environment', 'production');
Sentry.setTag('service', 'api-gateway');
Sentry.setTag('region', 'us-east-1');

When tracking RED method vs USE method metrics (Request rate, Errors, Duration), low-cardinality dimensions are enough. You don't need every user ID in your metrics; you need the error rate by service and endpoint.

Check your cardinality monthly. A tag that starts with 10 unique values can grow to 10,000 as your product evolves. Once it does, storage inflation is immediate and hard to undo.

Focused Instrumentation: Avoid the Noise Trap

Not every function call needs a span. Not every variable needs to be logged. Over-instrumentation is a hidden cost driver because it generates telemetry you'll never read.

Before you add an instrument, ask: "Would I debug this in production?" If the answer is no, skip it. Trade off breadth for depth in the things that matter.

Use structured logging best practices for high-volume events—debug logs, routine operations, state transitions. Error tracking is expensive; structured logs are cheap. Query the logs when you need to; use error tracking for incidents that matter.

// Good: errors to LightTrace, debug to logs
import * as Sentry from '@sentry/node';

// This goes to LightTrace (costs money)
if (userNotFound) {
  Sentry.captureException(new Error('User lookup failed'));
}

// This goes to logs (cheap, searchable)
console.log(JSON.stringify({
  event: 'user_lookup_attempt',
  user_id: userId,
  found: userNotFound === false,
  duration_ms: endTime - startTime,
}));

The result: fewer expensive error traces, cleaner signal in LightTrace, and all the debug context you need in logs. It's the pragmatic trade-off that reduces MTTR without exploding your bill.

Alert Rules: Pay Only for Signals You Act On

Every alert that your team ignores is wasted money. Alert rules are usually free or cheap to store, but they force your team to respond—and that response has a cost in context-switching and on-call burden.

Set alert rules based on actual incident response. Follow the error triage process to identify which errors demand immediate attention. Then automate alerts for only those patterns:

  • Alert on new-issue fingerprints (errors you've never seen before, not repeats)
  • Alert on frequency spikes in critical paths (5+ errors in 5 minutes from your payment API)
  • Skip alerts on low-severity warnings in non-critical flows

The effect is multiplied across your team. If you have 50 alert rules and your team ignores 40 of them, you've created overhead that slows response time and reduces MTTR rather than improving it.

Delete the alerts your team doesn't respond to. Let that be quarterly hygiene—review alert noise, kill what doesn't drive action.

Putting It Into Practice

Start with a focused audit: measure your current event volume, error rate, and storage cost. Then apply these in order:

Week 1: Enable head sampling at 50% for non-error transactions. Track your dashboards to ensure you're not missing critical signals.

Week 2: Add tail-sampling rules: 100% of errors, 100% of transactions slower than 500ms, 5% of successful fast transactions.

Week 3: Set retention tiers (90 days for unresolved errors, 30 for resolved, 7 for debug). Move old data to cold storage.

Week 4: Audit cardinality; move user IDs and request IDs from tags to context. Delete alert rules your team ignores.

By week four, most teams see 40–60% cost reductions while increasing visibility into what matters. You're not flying blind; you're focused.

Cost optimization is not a one-time project. As traffic patterns change—seasonal spikes, new services, migrations—you'll tune sampling and retention. The lever you're turning is not "less observability"; it's "smarter observability."

If you're running Sentry SDKs today, LightTrace offers the same SDK compatibility (point any unmodified Sentry SDK at LightTrace by changing only the DSN) with straightforward pricing and built-in retention and sampling controls. Follow the error tracking best practices handbook and apply these cost-optimization techniques from day one.

Start tracking errors in minutes

Start free with LightTrace today. No credit card needed—begin applying observability cost optimization telemetry to your stack in minutes.

Fix your next production error faster

Point any Sentry SDK at LightTrace — free up to 5,000 events/month.