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.
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
Metrics instrumentation flask #1186
Metrics instrumentation flask #1186
Changes from 9 commits
e91b396
139a1cc
02d7f29
528efb0
8278b7a
615bf12
aea88d4
754e062
cade131
d6026f8
41ab66f
ea828be
4273177
6bbfea2
ab37e05
22b11a5
9286231
a758eab
1a33b21
dda7548
9557035
27cdbc7
536bf25
bc89aa0
ab2bed1
0ba053f
9fe8a18
3516ec4
f45ca51
7cc4a50
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't all this logic be in
_start_response
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that is also a possible way. But we are starting span in before_request and ending it in teardown_request so I did the same for metrics too. Also here it says that, it is discouraged, I'm also not sure what to prefer. If doing it in start_response is more acceptable then I can make the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please do. That comment is relevant to only tracing API and they are referring to
update_name
call on span once it is started. It is discouraged because sampling decision would have already been made based on it and such edge cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test for the actual values in the histogram? This will test that what we are recording for duration value is actually accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I do not understand how can we get the value of time duration to test. Can you please give me an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point.sum
gives you the total duration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can get the actual value, but what will be the expected value? For three get requests
point.sum
value will be random time taken. We can not compare it to some hardcoded value. One possible solution I can think of is to mock thedefault_timer()
function that we use to get the timestamp, and with that, we test the time duration captured. But I'm not sure if it is the correct way to test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not have to make it exact hardcoded value. It can be
assertGreaterEqual
orassertAlmostEqual
with delta based on how much time a view/endpoint takes to respond back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger a request -> operation takes some time -> expected duration should be within x+/-∆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the test. Please have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still keep this and other functions private. They are not intended to be user accessible. If there is really need we can always change from private to public but not vice versa.