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

allow 0 value as a valid value for set() and observe() #172

Conversation

ymartin-ovh
Copy link

@ymartin-ovh ymartin-ovh commented Aug 26, 2024

This PR address usage of observe() and set() with a 0 value.

In my case, I get 0 with No value passed for nginx_upstream_http_connect_duration_seconds while observing tonumber(ngx.var.upstream_connect_time)

@ymartin-ovh ymartin-ovh force-pushed the dev/yannick.martin/allow-zero-value branch 2 times, most recently from 31acb01 to e42148f Compare August 26, 2024 16:30
@ymartin-ovh ymartin-ovh force-pushed the dev/yannick.martin/allow-zero-value branch from e42148f to cb67f4c Compare August 26, 2024 16:33
knyar added a commit that referenced this pull request Aug 27, 2024
@knyar
Copy link
Owner

knyar commented Aug 27, 2024

Hey, thank you for submitting a PR. I believe current code handles zero values correctly, I've just added a couple of tests explicitly testing that: 313303f

Note that you are expected to pass a number to set and observe. If ngx.var.upstream_connect_time is nil, tonumber(ngx.var.upstream_connect_time) would return nil as well, and the "No value passed" error would be expected.

@knyar knyar closed this Aug 27, 2024
@ymartin-ovh
Copy link
Author

Thanks for feedback. I miss that "not 0" in lua returns false. Sorry.

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

Successfully merging this pull request may close these issues.

2 participants