21
21
#include " sha1.hpp"
22
22
#include " string_resize.hpp"
23
23
#include " websocket.hpp"
24
- #include " ylt/metric/counter.hpp"
25
- #include " ylt/metric/gauge.hpp"
26
- #include " ylt/metric/histogram.hpp"
27
- #include " ylt/metric/metric.hpp"
28
24
#ifdef CINATRA_ENABLE_GZIP
29
25
#include " gzip.hpp"
30
26
#endif
31
- #include " metric_conf.hpp"
32
27
#include " ylt/coro_io/coro_file.hpp"
33
28
#include " ylt/coro_io/coro_io.hpp"
34
29
@@ -52,14 +47,9 @@ class coro_http_connection
52
47
request_(parser_, this ),
53
48
response_(this ) {
54
49
buffers_.reserve (3 );
55
-
56
- cinatra_metric_conf::server_total_fd_inc ();
57
50
}
58
51
59
- ~coro_http_connection () {
60
- cinatra_metric_conf::server_total_fd_dec ();
61
- close ();
62
- }
52
+ ~coro_http_connection () { close (); }
63
53
64
54
#ifdef CINATRA_ENABLE_SSL
65
55
bool init_ssl (const std::string &cert_file, const std::string &key_file,
@@ -126,20 +116,13 @@ class coro_http_connection
126
116
CINATRA_LOG_WARNING << " read http header error: " << ec.message ();
127
117
}
128
118
129
- cinatra_metric_conf::server_failed_req_inc ();
130
119
close ();
131
120
break ;
132
121
}
133
122
134
- if (cinatra_metric_conf::enable_metric) {
135
- start = std::chrono::system_clock::now ();
136
- cinatra_metric_conf::server_total_req_inc ();
137
- }
138
-
139
123
const char *data_ptr = asio::buffer_cast<const char *>(head_buf_.data ());
140
124
int head_len = parser_.parse_request (data_ptr, size, 0 );
141
125
if (head_len <= 0 ) {
142
- cinatra_metric_conf::server_failed_req_inc ();
143
126
CINATRA_LOG_ERROR << " parse http header error" ;
144
127
close ();
145
128
break ;
@@ -153,9 +136,6 @@ class coro_http_connection
153
136
if (type != content_type::chunked && type != content_type::multipart) {
154
137
size_t body_len = parser_.body_len ();
155
138
if (body_len == 0 ) {
156
- if (cinatra_metric_conf::enable_metric) {
157
- cinatra_metric_conf::server_total_recv_bytes_inc (head_len);
158
- }
159
139
if (parser_.method () == " GET" sv) {
160
140
if (request_.is_upgrade ()) {
161
141
#ifdef CINATRA_ENABLE_GZIP
@@ -175,16 +155,6 @@ class coro_http_connection
175
155
}
176
156
response_.set_delay (true );
177
157
}
178
- else {
179
- if (cinatra_metric_conf::enable_metric) {
180
- mid = std::chrono::system_clock::now ();
181
- double count =
182
- std::chrono::duration_cast<std::chrono::microseconds>(mid -
183
- start)
184
- .count ();
185
- cinatra_metric_conf::server_read_latency_observe (count);
186
- }
187
- }
188
158
}
189
159
}
190
160
else if (body_len <= head_buf_.size ()) {
@@ -194,7 +164,6 @@ class coro_http_connection
194
164
memcpy (body_.data (), data_ptr, body_len);
195
165
head_buf_.consume (head_buf_.size ());
196
166
}
197
- cinatra_metric_conf::server_total_recv_bytes_inc (head_len + body_len);
198
167
}
199
168
else {
200
169
size_t part_size = head_buf_.size ();
@@ -209,22 +178,9 @@ class coro_http_connection
209
178
size_to_read);
210
179
if (ec) {
211
180
CINATRA_LOG_ERROR << " async_read error: " << ec.message ();
212
- cinatra_metric_conf::server_failed_req_inc ();
213
181
close ();
214
182
break ;
215
183
}
216
- else {
217
- if (cinatra_metric_conf::enable_metric) {
218
- cinatra_metric_conf::server_total_recv_bytes_inc (head_len +
219
- body_len);
220
- mid = std::chrono::system_clock::now ();
221
- double count =
222
- std::chrono::duration_cast<std::chrono::microseconds>(mid -
223
- start)
224
- .count ();
225
- cinatra_metric_conf::server_read_latency_observe (count);
226
- }
227
- }
228
184
}
229
185
}
230
186
@@ -409,14 +365,6 @@ class coro_http_connection
409
365
}
410
366
}
411
367
412
- if (cinatra_metric_conf::enable_metric) {
413
- mid = std::chrono::system_clock::now ();
414
- double count =
415
- std::chrono::duration_cast<std::chrono::microseconds>(mid - start)
416
- .count ();
417
- cinatra_metric_conf::server_req_latency_observe (count);
418
- }
419
-
420
368
response_.clear ();
421
369
request_.clear ();
422
370
buffers_.clear ();
@@ -430,10 +378,6 @@ class coro_http_connection
430
378
}
431
379
432
380
async_simple::coro::Lazy<bool > reply (bool need_to_bufffer = true ) {
433
- if (response_.status () >= status_type::bad_request) {
434
- if (cinatra_metric_conf::enable_metric)
435
- cinatra_metric_conf::server_failed_req_inc ();
436
- }
437
381
std::error_code ec;
438
382
size_t size;
439
383
if (multi_buf_) {
@@ -444,18 +388,12 @@ class coro_http_connection
444
388
for (auto &buf : buffers_) {
445
389
send_size += buf.size ();
446
390
}
447
- if (cinatra_metric_conf::enable_metric) {
448
- cinatra_metric_conf::server_total_send_bytes_inc (send_size);
449
- }
450
391
std::tie (ec, size) = co_await async_write (buffers_);
451
392
}
452
393
else {
453
394
if (need_to_bufffer) {
454
395
response_.build_resp_str (resp_str_);
455
396
}
456
- if (cinatra_metric_conf::enable_metric) {
457
- cinatra_metric_conf::server_total_send_bytes_inc (resp_str_.size ());
458
- }
459
397
std::tie (ec, size) = co_await async_write (asio::buffer (resp_str_));
460
398
}
461
399
0 commit comments