Skip to content

Commit d35bcf4

Browse files
committed
fix handling of encoding request splits + add more accurate batch size impl
1 parent be7c5ef commit d35bcf4

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/sinks/statsd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod batch;
12
mod config;
23
mod encoder;
34
mod normalizer;

src/sinks/statsd/request_builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ impl IncrementalRequestBuilder<Vec<Metric>> for StatsdRequestBuilder {
115115
if request_buf_len != 0
116116
&& (request_buf_len + self.encode_buf.len() > self.request_max_size)
117117
{
118+
// The metric, as encoded, would cause us to exceed our maximum request size, so
119+
// store it off to the side and finalize the current request.
120+
pending = Some(metric);
118121
break;
119122
}
120123

src/sinks/statsd/sink.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use vector_core::{
1616
use crate::sinks::util::SinkBuilderExt;
1717

1818
use super::{
19-
normalizer::StatsdNormalizer, request_builder::StatsdRequestBuilder, service::StatsdRequest,
19+
batch::StatsdBatchSizer, normalizer::StatsdNormalizer, request_builder::StatsdRequestBuilder,
20+
service::StatsdRequest,
2021
};
2122

2223
pub(crate) struct StatsdSink<S> {
@@ -57,7 +58,10 @@ where
5758
// other metric types in type-specific ways i.e. incremental gauge updates use a
5859
// different syntax, etc.
5960
.normalized_with_default::<StatsdNormalizer>()
60-
.batched(self.batch_settings.into_byte_size_config())
61+
.batched(
62+
self.batch_settings
63+
.into_item_size_config(StatsdBatchSizer::default()),
64+
)
6165
// We build our requests "incrementally", which means that for a single batch of
6266
// metrics, we might generate N requests to represent all of the metrics in the batch.
6367
//

0 commit comments

Comments
 (0)