Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 2917fcc

Browse files
authored
static_assert() to document assumption about trace_id length. (#403)
1 parent 5302c06 commit 2917fcc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

opencensus/trace/internal/sampler.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ uint64_t CalculateThresholdFromBuffer(const TraceId& trace_id) {
4242
const uint8_t* buf = reinterpret_cast<const uint8_t*>(trace_id.Value());
4343
uint64_t res = 0;
4444
// We only use the first 8 bytes of TraceId.
45+
static_assert(TraceId::kSize >= 8, "TraceID must be at least 8 bytes long.");
4546
for (int i = 0; i < 8; ++i) {
4647
res |= (static_cast<uint64_t>(buf[i]) << (i * 8));
4748
}

0 commit comments

Comments
 (0)