-
Notifications
You must be signed in to change notification settings - Fork 34
/
graphite_module_v1_15_4.patch
123 lines (108 loc) · 3.92 KB
/
graphite_module_v1_15_4.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index 3a0e150..0eb06aa 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -1363,6 +1363,16 @@ ngx_ssl_handshake(ngx_connection_t *c)
ngx_ssl_clear_error(c->log);
+#if (NGX_GRAPHITE)
+ struct timeval tp;
+ if (c->ssl->handshake_process == 0) {
+ c->ssl->handshake_process = 1;
+ ngx_gettimeofday(&tp);
+ c->ssl->handshake_start_sec = tp.tv_sec;
+ c->ssl->handshake_start_msec = tp.tv_usec / 1000;
+ }
+#endif
+
n = SSL_do_handshake(c->ssl->connection);
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_do_handshake: %d", n);
@@ -1401,6 +1411,13 @@ ngx_ssl_handshake(ngx_connection_t *c)
#endif
#endif
+#if (NGX_GRAPHITE)
+ c->ssl->handshake_process = 0;
+ ngx_gettimeofday(&tp);
+ c->ssl->handshake_end_sec = tp.tv_sec;
+ c->ssl->handshake_end_msec = tp.tv_usec / 1000;
+#endif
+
return NGX_OK;
}
diff --git a/src/event/ngx_event_openssl.h b/src/event/ngx_event_openssl.h
index abd84cc..6735aa9 100644
--- a/src/event/ngx_event_openssl.h
+++ b/src/event/ngx_event_openssl.h
@@ -89,6 +89,14 @@ struct ngx_ssl_connection_s {
u_char early_buf;
+#if (NGX_GRAPHITE)
+ ngx_uint_t handshake_process;
+ time_t handshake_start_sec;
+ ngx_msec_t handshake_start_msec;
+ time_t handshake_end_sec;
+ ngx_msec_t handshake_end_msec;
+#endif
+
unsigned handshaked:1;
unsigned renegotiation:1;
unsigned buffer:1;
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index e4c343c..1f1bd43 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -427,7 +427,16 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
+#if (NGX_GRAPHITE)
+ struct timeval start_tp;
+ ngx_gettimeofday(&start_tp);
+#endif
rc = ngx_http_gzip_filter_deflate(r, ctx);
+#if (NGX_GRAPHITE)
+ struct timeval stop_tp;
+ ngx_gettimeofday(&stop_tp);
+ r->gzip_time += (stop_tp.tv_sec - start_tp.tv_sec) * 1000 + (stop_tp.tv_usec - start_tp.tv_usec) / 1000.0;
+#endif
if (rc == NGX_OK) {
break;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index c57ec00..8e97fa3 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1166,7 +1166,17 @@ ngx_http_core_content_phase(ngx_http_request_t *r,
if (r->content_handler) {
r->write_event_handler = ngx_http_request_empty_handler;
- ngx_http_finalize_request(r, r->content_handler(r));
+#if (NGX_GRAPHITE)
+ struct timeval start_tp;
+ ngx_gettimeofday(&start_tp);
+#endif
+ ngx_int_t rc = r->content_handler(r);
+#if (NGX_GRAPHITE)
+ struct timeval stop_tp;
+ ngx_gettimeofday(&stop_tp);
+ r->content_time += (stop_tp.tv_sec - start_tp.tv_sec) * 1000 + (stop_tp.tv_usec - start_tp.tv_usec) / 1000.0;
+#endif
+ ngx_http_finalize_request(r, rc);
return NGX_OK;
}
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 6bfff96..c67378d 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -586,6 +586,20 @@ struct ngx_http_request_s {
unsigned http_minor:16;
unsigned http_major:16;
+
+#define NGX_GRAPHITE_PATCH
+
+#if (NGX_GRAPHITE)
+ double content_time;
+#endif
+
+#if ((NGX_HTTP_GZIP) && (NGX_GRAPHITE))
+ double gzip_time;
+#endif
+
+#if (NGX_GRAPHITE)
+ double lua_time;
+#endif
};