Skip to content

Commit 40373eb

Browse files
bm1549claude
andcommitted
Replace assert with conditional for to_chars error handling
assert is compiled out in release builds, so handle the error by silently skipping the ksr tag instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 913ad91 commit 40373eb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/datadog/trace_segment.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,10 @@ void TraceSegment::make_sampling_decision_if_null() {
331331
const auto [ptr, ec] = std::to_chars(buf.data(), buf.data() + buf.size(),
332332
*sampling_decision_->configured_rate,
333333
std::chars_format::general, 6);
334-
assert(ec == std::errc());
335-
trace_tags_.emplace_back(tags::internal::ksr, std::string(buf.data(), ptr));
334+
if (ec == std::errc()) {
335+
trace_tags_.emplace_back(tags::internal::ksr,
336+
std::string(buf.data(), ptr));
337+
}
336338
}
337339
}
338340

0 commit comments

Comments
 (0)