[python] implement /flush endpoint in python weblogs#6772
Draft
[python] implement /flush endpoint in python weblogs#6772
Conversation
Contributor
|
|
fb3c1b8 to
45dbd83
Compare
|
✨ Fix all issues with BitsAI or with Cursor
|
8626136 to
fdd0cd2
Compare
5 tasks
Add GET /flush to flask, fastapi, django, and tornado weblogs. The endpoint calls tracer.flush() and telemetry_writer.periodic(force_flush=True) to force all pending data to be sent to the agent. Enable python in the flush() call in containers.py, and set library_interface_timeout to 0 for python (alongside nodejs and ruby) now that explicit flushing is supported.
Same approach as Ruby's flush implementation. Without the sleep, the library_interface_timeout drops to 0 and RC polling sequences don't have enough time to complete before the container is stopped.
app_shutdown() calls periodic(force_flush=True, shutting_down=True) which sends the app-closing event the agent needs to finalise the telemetry batch. Without it, queued metrics (e.g. IAST executed/instrumented.source) were never forwarded by the agent before system-tests read them. Also removes the now-unnecessary time.sleep(0.2) since app_shutdown() is fully synchronous, and the unused `import time` in all four weblogs. /flush is called exactly once at the end of the test suite, so calling disable() (which app_shutdown does internally) is safe.
fdd0cd2 to
4bc8a12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Faster run, better guarantees for telemetry arrival.
Changes
Add GET /flush to flask, fastapi, django, and tornado weblogs. The endpoint calls tracer.flush() and telemetry_writer.periodic(force_flush=True) to force all pending data to be sent to the agent.
Enable python in the flush() call in containers.py, and set library_interface_timeout to 0 for python (alongside nodejs and ruby) now that explicit flushing is supported.
Workflow
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
tests/ormanifests/is modified ? I have the approval from R&P teambuild-XXX-imagelabel is present