File tree Expand file tree Collapse file tree
src/sources/datadog_agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,8 +67,9 @@ pub(crate) fn decode_log_body(
6767 api_key : Option < Arc < str > > ,
6868 source : & DatadogAgentSource ,
6969) -> Result < Vec < Event > , ErrorMessage > {
70- if body. is_empty ( ) {
70+ if body. is_empty ( ) || body . as_ref ( ) == b"{}" {
7171 // The datadog agent may send an empty payload as a keep alive
72+ // https://github.com/DataDog/datadog-agent/blob/5a6c5dd75a2233fbf954e38ddcc1484df4c21a35/pkg/logs/client/http/destination.go#L52
7273 debug ! (
7374 message = "Empty payload ignored." ,
7475 internal_log_rate_limit = true
Original file line number Diff line number Diff line change @@ -120,6 +120,27 @@ fn test_decode_log_body() {
120120 QuickCheck :: new ( ) . quickcheck ( inner as fn ( Vec < LogMsg > ) -> TestResult ) ;
121121}
122122
123+ #[ test]
124+ fn test_decode_log_body_empty_object ( ) {
125+ let body = Bytes :: from ( "{}" ) ;
126+ let api_key = None ;
127+ let decoder = crate :: codecs:: Decoder :: new (
128+ Framer :: Bytes ( BytesDecoder :: new ( ) ) ,
129+ Deserializer :: Bytes ( BytesDeserializer ) ,
130+ ) ;
131+
132+ let source = DatadogAgentSource :: new (
133+ true ,
134+ decoder,
135+ "http" ,
136+ test_logs_schema_definition ( ) ,
137+ LogNamespace :: Legacy ,
138+ ) ;
139+
140+ let events = decode_log_body ( body, api_key, & source) . unwrap ( ) ;
141+ assert_eq ! ( events. len( ) , 0 ) ;
142+ }
143+
123144#[ test]
124145fn generate_config ( ) {
125146 crate :: test_util:: test_generate_config :: < DatadogAgentConfig > ( ) ;
You can’t perform that action at this time.
0 commit comments