Skip to content

Commit

Permalink
now latency_ms and upstream_latency_ms represent "sum of" the variabl…
Browse files Browse the repository at this point in the history
…e instead of "average"
  • Loading branch information
Lax committed Jun 22, 2015
1 parent acbc298 commit fe7e2f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ The output contains a list of k/v for the accounting metrics, in the sequence of
| `requests` | count of total requests processed |
| `bytes_in` | total bytes receiverd by the server |
| `bytes_out` | total bytes send out by the server |
| `latency_ms` | average `$request_time`, in `millisecond` |
| `upstream_latency_ms` | average `$upstream_response_time`, in `millisecond` |
| `latency_ms` | a sum of `$request_time`, in `millisecond` |
| `upstream_latency_ms` | a sum of `$upstream_response_time`, in `millisecond` |
| `200` / `302` / `400` / `404` / `500` ... | count of requests which response is with http code `200`/`302`/`400`/`404`/`500`, etc |

# Branches
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_accounting_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct {
ngx_uint_t bytes_in;
ngx_uint_t bytes_out;
ngx_uint_t total_latency_ms;
ngx_uint_t upstream_total_latency_ms;
ngx_uint_t total_upstream_latency_ms;
ngx_uint_t *http_status_code;
} ngx_http_accounting_stats_t;

Expand Down
8 changes: 4 additions & 4 deletions src/ngx_http_accounting_worker_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ngx_http_accounting_handler(ngx_http_request_t *r)
stats->bytes_in += r->request_length;
stats->bytes_out += r->connection->sent;
stats->total_latency_ms += req_latency_ms;
stats->upstream_total_latency_ms += upstream_req_latency_ms;
stats->total_upstream_latency_ms += upstream_req_latency_ms;
stats->http_status_code[http_status_code_to_index_map[status]] += 1;

return NGX_OK;
Expand Down Expand Up @@ -169,15 +169,15 @@ worker_process_write_out_stats(u_char *name, size_t len, void *val, void *para1,
stats->nr_requests,
stats->bytes_in,
stats->bytes_out,
stats->total_latency_ms / (stats->nr_requests > 0 ? stats->nr_requests : 1),
stats->upstream_total_latency_ms / (stats->nr_requests > 0 ? stats->nr_requests : 1)
stats->total_latency_ms,
stats->total_upstream_latency_ms
);

stats->nr_requests = 0;
stats->bytes_in = 0;
stats->bytes_out = 0;
stats->total_latency_ms = 0;
stats->upstream_total_latency_ms = 0;
stats->total_upstream_latency_ms = 0;

for (i = 0; i < http_status_code_count; i++) {
if(stats->http_status_code[i] > 0) {
Expand Down

1 comment on commit fe7e2f5

@Lax
Copy link
Owner Author

@Lax Lax commented on fe7e2f5 Oct 1, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #7

Please sign in to comment.