Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collects information only for the last request #359

Open
JduMoment opened this issue Jan 16, 2025 · 0 comments
Open

Collects information only for the last request #359

JduMoment opened this issue Jan 16, 2025 · 0 comments

Comments

@JduMoment
Copy link

JduMoment commented Jan 16, 2025

Hi again.

I hope you're not tired of me yet :)

I used the Flask instructions to set up the profiler in our application.

As far as I understand, it doesn't matter which file we embed the code from the instructions in. Since it clings to the app, all requests must be processed.

As far as I understand, it doesn't matter which file we embed the code from the instructions in. Since it clings to the app, all requests should be processed, but I have a problem. For some reason, the profiling shows information for the last few seconds. It seems that there is only information about the last request.

For example, I turned on the profiler and did not go to the results page for 10-20 minutes. To make sure that the profiler didn't stop working, I put print in front of profile.stop(). I chose speedscope to display the information because it has a timeline at the top, which allowed me to somehow understand how long the information was collected. The timeline scale showed about 110 ms. After that, I made a couple of different queries and immediately saved the result. The schedule was identical.

it is my app:

server = Flask( __name__, static_folder="/app/static/", template_folder=get_absolute_path(__file__, "templates"), static_url_path="/static_sphere", # Чтоб не мешался blueprint-ам без префикса )

launch is in wsgi.py

from sphere import server as application
@application.before_request
def before_request():
    if "profile" in request.args:
        g.profiler = Profiler()
        g.profiler.start()


@application.after_request
def after_request(response):
    if not hasattr(g, "profiler"):
        return response
    g.profiler.stop()
    output_html = g.profiler.output(renderers.SpeedscopeRenderer(timeline=True, processor_options=True))
    return make_response(output_html)


with application.app_context():
    sphere_init()
    sphere_conf.configure()
    if __name__ == "__main__":
        application.run()

I'm sorry if my question seems silly, but I'm not a very experienced developer, and this is the first time I've encountered profilers in my life. I hope for your help and patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant