fix: missing break statements in CounterCollection::logToTraceEvent#13166
fix: missing break statements in CounterCollection::logToTraceEvent#13166fmartinez09 wants to merge 1 commit intoapple:mainfrom
Conversation
gxglass
left a comment
There was a problem hiding this comment.
Thanks for having a look. AI review (see below) finds another similar bug which would be worth fixing while here.
Regarding the new test case, I feel it is too limited and specific to justify its cost of 25 lines of code. A more general and lighter weight solution would be to enable the compiler flag that the AI suggests. I assume there are ways to override that as needed if fall-through is actually desired.
Also there might be broader-coverage ways of improving test coverage here that you could look into. I haven't thought about it other than noting that the current number of TEST_CASE in this file is zero, which seems like it has a high probability of not being the right number. What those missing test cases (good ones) might be I don't know.
AI review:
6db51c5 to
48b3bb9
Compare
|
Thanks for the review! Applied:
On enabling
I also found 4 intentional fallthroughs in Scoping the flag to |
Problem
CounterCollection::logToTraceEventhas a switch onc->modelwith nobreakstatements between theOTLPandSTATSDcases. When a counteris configured with
model=OTLP, the OTLP branch correctly populatesMetricCollection::sumMap, but control then falls through to the STATSDbranch and silently pushes to
MetricCollection::statsd_message. Adeployment configured for OTLP metrics is also emitting StatsD-format
data on every counter log cycle, regardless of the operator's intent.
I encountered this while studying the metrics path referenced in #12679.
Solution
Add explicit
breakstatements after theOTLPandSTATSDcases.The
NONE/defaultcase is last and does not require a break.Testing
Added unit test
/fdbrpc/Stats/CounterCollectionFallthroughinStats.cppthat forcesMETRICS_DATA_MODEL=otel, logs a counter,and asserts that
sumMapis populated andstatsd_messageis empty.Verified:
ASSERT_EQ(statsd_message.size(), 0)(Test Cases Failed = 1)Test Cases Failed = 0)Run with:
./bin/fdbserver -r unittests -f /fdbrpc/Stats/CounterCollectionFallthrough