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

Does'nt report the timer values in the influx #68

Open
saikiran121993 opened this issue Mar 15, 2019 · 4 comments
Open

Does'nt report the timer values in the influx #68

saikiran121993 opened this issue Mar 15, 2019 · 4 comments

Comments

@saikiran121993
Copy link

saikiran121993 commented Mar 15, 2019

Hi,

I am using the influx reporter when I run timer function there insertion in record with time but all the values are null, I can see mean value of the function using getmean() but there is no reflection of the timer values in influx DB. The code I am using is given below

reporter = InfluxReporter(registry, reporting_interval=1, database='mydatabase', server='myserver.local', username='myusername', password='mypassword', port='8186')
reporter.start()


time1 = registry.timer("func1_calls")

# def testTimer():
#     with timer("test").time():
#         print("I am from with statement")
#         print(timer("test").get_mean())
#         reporter.report_now()

@time_calls
def func1():
    print("Hey! I am from function 1")

while True:
        time.sleep(1)
        func1()

image

@omergertel
Copy link
Owner

I haven't used this reporter myself. Feel free to offer a pull request with a fix and I'll gladly merge it

@saikiran121993
Copy link
Author

saikiran121993 commented Mar 15, 2019

A quick change in Timer Documentation instead of test_calls it should be just alias name when you are using with statement

from time import sleep
from pyformance import timer
with timer("test").time():
   sleep(0.1)
print(timer("test").get_mean())

Output: 0.10001015663146973

@bitchkat
Copy link

bitchkat commented Mar 15, 2019

Your InfluxReporter is passing a registry to the constructor but the measured code is not creating timers from this registry.

Since you explicitly created a timer in this registry

time1 = registry.timer("func1_calls")
but never timed anything against this, the "func1_calls" timer in registry will always have 0 values.

If you use the with style and reference a timer from the registry it will work:

` from time import sleep

from pyformance import timer
with registry.timer("test").time():
  sleep(0.1)
print(registry.timer("test").get_mean())`

@saikiran121993
Copy link
Author

saikiran121993 commented Mar 18, 2019

Thanks 👍 @bitchkat

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

3 participants