@@ -167,16 +167,19 @@ const TMeteringSink::FlushParameters TMeteringSink::GetFlushParameters(const EMe
167
167
case EMeteringJson::UsedStorageV1: {
168
168
ui64 duration = (now - lastFlush).MilliSeconds ();
169
169
ui64 avgUsage = duration > 0 ? CurrentUsedStorage_ * 1_MB * 1000 / duration : 0 ;
170
+ ui64 quantity = (avgUsage > 0 ) ? 1 : 0 ;
170
171
171
172
CurrentUsedStorage_ = 0 ;
172
173
173
174
return TMeteringSink::FlushParameters (
174
175
" used_storage" ,
175
176
" ydb.serverless.v1" ,
176
- " byte*second"
177
+ " byte*second" ,
178
+ quantity
177
179
).withTags ({
178
180
{" ydb_size" , avgUsage}
179
181
})
182
+ .withImplicitZero ()
180
183
.withVersion (" 1.0.0" );
181
184
}
182
185
@@ -195,7 +198,7 @@ void TMeteringSink::Flush(TInstant now, bool force) {
195
198
continue ;
196
199
}
197
200
198
- auto parameters = GetFlushParameters (whichOne, now, lastFlush);
201
+ const auto parameters = GetFlushParameters (whichOne, now, lastFlush);
199
202
200
203
if (parameters.OneFlush ) {
201
204
const auto isTimeToFlushUnits = now.Hours () > lastFlush.Hours ();
@@ -218,13 +221,15 @@ void TMeteringSink::Flush(TInstant now, bool force) {
218
221
auto interval = TInstant::Hours (lastFlush.Hours ()) + Parameters_.FlushLimit ;
219
222
220
223
auto tryFlush = [&](TInstant start, TInstant finish) {
221
- const auto metricsJson = GetMeteringJson (
222
- parameters,
223
- parameters.Quantity * (finish.Seconds () - start.Seconds ()),
224
- start,
225
- finish,
226
- now);
227
- FlushFunction_ (metricsJson);
224
+ if (parameters.Quantity > 0 || !parameters.ImplicitZero ) {
225
+ const auto metricsJson = GetMeteringJson (
226
+ parameters,
227
+ parameters.Quantity * (finish.Seconds () - start.Seconds ()),
228
+ start,
229
+ finish,
230
+ now);
231
+ FlushFunction_ (metricsJson);
232
+ }
228
233
229
234
lastFlush = finish;
230
235
};
0 commit comments