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

sanic multi worker metrics are not populated #58

Open
alexterman opened this issue Jul 24, 2018 · 2 comments
Open

sanic multi worker metrics are not populated #58

alexterman opened this issue Jul 24, 2018 · 2 comments

Comments

@alexterman
Copy link

I am trying to add metrics to sanic application.
When running 1 worker everything looks fine, but when configuring more workers no metrics being sent to carbon.

import random
import time

from sanic import Sanic
from sanic.response import json

from pyformance import MetricsRegistry
from pyformance.reporters.carbon_reporter import CarbonReporter

registry = MetricsRegistry()
__reporter__ = CarbonReporter(registry=registry,
                              reporting_interval=10,
                              prefix='sanic',
                              server='localhost',
                              port=2003)
__reporter__.start()
app = Sanic()

@app.route("/api/v1/foo", methods=["POST"])
def foo(request):

    timer = registry.timer(".foo")
    with timer.time():
        time.sleep(random.randint(1, 2))
        return json({"status": True})

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=20100, workers=1, access_log=False, debug=False)
@omergertel
Copy link
Owner

Sorry, no idea what Sanic is. Could this be because of threading or forking?

@alexterman
Copy link
Author

@omergertel thanks for the answer, is pyformance should be used in a single-threaded environment?

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

2 participants