[RFC] Add extended stats - #893
Conversation
ddb4076 to
b267e10
Compare
- Add a structure to track internally generated errors - Structure the stats a pluggable modules. New status reporting code can use the `h2o_config_register_status_handler` (for queries that need to access per thread data) or `h2o_config_register_simple_status_handler` (for queries that can be run in the request context) APIs in order to add new statuses - requests statuses and error reporting is moved under `lib/handler/status/`
|
Here's another attempt at the PR: i've added a registering mechanism for request handlers ('main', 'requests' and 'errors'), and split requests and errors to their own file. I've also removed the jemalloc bits: haven't figured out how to make the detection work in the static linking case, and it feels like it should be a different PR anyway. |
| h2o_iovec_t (*assemble_cb)(void *ctx); | ||
| void (*done_cb)(void *ctx); | ||
| } per_thread; | ||
| }; |
There was a problem hiding this comment.
How about having a single type that optionally defines per_thread_cb, instead of having two distinct types.
For example, we could define three callbacks: init, per_thread, final, with the first two being optional callbacks. final should either a) gather the information obtained by calls to per_thread (that updates the struct costructed by init), or b) simply return the information available in a global storage (in this case, init and per_thread can be set to NULL).
Also, you cannot allocate memory from req->pool in a different thread (than the request belongs to). Therefore, you should not pass src_req to alloc_context_cb (and considering the fact that the status handler is rarely called, I think it is not mandatory to use memory pools in the handler).
|
Thank you for updating the PR. It seems like we've made a big progress forward. Thank you very much. I've left high-level design comments inline. Would you please consider them? |
|
Hello @kazuho, Thanks for taking the time to review the PR! I'll be addressing your comments shortly. |
`init` and `per_thread` callbacks optional. Only `final` will be mandatory. - Remove GNUisms - Fix the doc to reflect the current implementation.
- Use predefined functions for the callsites where the status is known, avoiding one indirection level
| pthread_mutex_t mutex; | ||
| h2o_iovec_t data; | ||
| size_t num_remaining_threads; | ||
| h2o_globalconf_t *gconf; |
There was a problem hiding this comment.
I believe you do not need to retain a pointer to h2o_globalconf_t. It can be reached by accessing h2o_context_t::globalconf.
update the counters directly from that function, instead of relying on
`h2o_context_report_http1_error`
- Remove `h2o_context_report_http1_error` and `E_HTTP_{4,5,X}XX` enums:
Every call side now uses a well known http return code.
- Simplify the `status_list` logic by calling `h2o_contains_token`. We
also use `,` as a separator between the modules, rather than the
reserved `|` (update docs and the test).
- Add a test case verifying the increment of the 404 counter
|
@deweerdt Should I review the changes now or are you planning to push more? |
|
@kazuho, I believe the changes are ready for review, thanks! |
| h2o_socket_read_stop(conn->sock); | ||
| conn->req.http1_is_persistent = 0; | ||
| h2o_send_error(&conn->req, status, reason, body, H2O_SEND_ERROR_HTTP1_CLOSE_CONNECTION); | ||
| h2o_send_error_generic(&conn->req, status, reason, body, H2O_SEND_ERROR_HTTP1_CLOSE_CONNECTION); |
There was a problem hiding this comment.
Should we better invoke h2o_send_error_XXX in the callers of entity_read_send_error to collect the error codes?
|
@deweerdt I've gone through the code and left my comments. Please update the code or let me know how you think. Thank you in advance. |
- simplify `st_h2o_status_handler_t` error handler in `init` removing error handling that level, and deferring to `final`. - Remove H2O_HTTP2_ERROR_OTHER in favor of dedicated `read_closed` and `write_closed` errors. - rename http1 errors under H2O_STATUS_ERROR_XXX - replace the remaining callers to `h2o_send_error_generic` to use hardcoded errors - append `DECL_` to the names of function declaring macros for clarity
|
Thank you for the updates. All we have left are some naming issues. Once they get updated I will merge the PR (or if you want me to change the names please let me know). PS. Regarding the names, it might be better to rename the "error" status handler to "events" status handler considering the fact that it can be used to collect numbers of any kind of events (and that italready collects the number of connection closes). |
I'll update the code, thanks. I'll await your decision on the json formatting and the naming of the handler below before updating the PR.
My initial idea was to mirror what would be found in the error log, but you're right that collecting read and write closes are better described by being events than errors. Another argument in favor of 'events' is that those aren't really errors that are actionable by the administrator, they are just useful to monitor because a sudden change in rates might mean that an action is required. How about 'networking_events'? |
s/http1_status_errors/emitted_error_status/ s/DECL_H2O_SEND_ERROR_XXX/H2O_SEND_ERROR_XXX/ s/errors_status_ctx/st_errors_status_ctx_t/ rename aggregated errors to something that matches the data being aggregated
I do not have a strong preference, but using the former with PS. I'd also suggest using
Agreed.
I'd suggest omitting |
- Modify the json key naming: s/_/-/ and add a dot to denote categories
| " \"http1-errors.417\": %" PRIu64 ",\n" | ||
| " \"http1-errors.500\": %" PRIu64 ",\n" | ||
| " \"http1-errors.502\": %" PRIu64 ",\n" | ||
| " \"http1-errors.503\": %" PRIu64 ",\n" |
There was a problem hiding this comment.
Please rename the errors to status-errors, as discussed in #893 (comment).
I believe that is the only change required to getting this merged. Thank you!
[RFC] Add extended stats clang-format applied to the updated files
|
Thank you for your hard work! Merged to master. |
This PR aims at adding optional additional counters accessible via the status page. This would be enabled when
statushas the valueEXTENDED.I post this mainly as a conversation starter, in particular to discuss how the information is gathered. Following our offline discussion, my goal would be to add also http2 counters as well as duration counters in
proxy.c.