File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ endif::[]
4848* Restrict length of Starlette request bodies {pull}1549[#1549]
4949* Fix error when using elasticsearch(sniff_on_start=True) {pull}1618[#1618]
5050* Improve handling of ignored URLs and capture_body=off for Starlette {pull}1549[#1549]
51+ * Fix possible error in the transport flush for Lambda functions {pull}1628[#1628]
5152
5253
5354
Original file line number Diff line number Diff line change @@ -176,11 +176,11 @@ def _process_queue(self):
176176 if flush :
177177 if buffer_written :
178178 self ._flush (buffer , forced_flush = forced_flush )
179- elif forced_flush and "/localhost:" in self .client .config .server_url :
179+ elif forced_flush and any ( x in self .client .config .server_url for x in ( "/localhost:" , "/127.0.0.1:" )) :
180180 # No data on buffer, but due to manual flush we should send
181181 # an empty payload with flushed=true query param, but only
182182 # to a local APM server (or lambda extension)
183- self .send (None , flushed = True )
183+ self .send ("" , forced_flush = True )
184184 self ._last_flush = timeit .default_timer ()
185185 buffer = self ._init_buffer ()
186186 buffer_written = False
Original file line number Diff line number Diff line change @@ -264,3 +264,13 @@ def test_flushed_arg(sending_elasticapm_client):
264264 sending_elasticapm_client ._transport .flush ()
265265
266266 assert sending_elasticapm_client .httpserver .requests [0 ].args ["flushed" ] == "true"
267+
268+
269+ @pytest .mark .parametrize ("sending_elasticapm_client" , [{"api_request_time" : "100ms" }], indirect = True )
270+ def test_flushed_arg_with_wait (sending_elasticapm_client ):
271+ sending_elasticapm_client .begin_transaction ("test_type" )
272+ sending_elasticapm_client .end_transaction ("test" )
273+ time .sleep (0.2 )
274+ sending_elasticapm_client ._transport .flush ()
275+
276+ assert sending_elasticapm_client .httpserver .requests [1 ].args ["flushed" ] == "true"
You can’t perform that action at this time.
0 commit comments