Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheatfate committed Aug 28, 2023
1 parent c40e4a7 commit d1436cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 61 deletions.
33 changes: 3 additions & 30 deletions presto/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,8 @@ export SocketFlags
when defined(metrics):
import metrics

declareGauge presto_client_1xx_response_count,
"Number of received HTTP(s) 1xx client responses",
labels = ["endpoint", "status"]
declareGauge presto_client_2xx_response_count,
"Number of received HTTP(s) 2xx client responses",
labels = ["endpoint", "status"]
declareGauge presto_client_3xx_response_count,
"Number of received HTTP(s) 3xx client responses",
labels = ["endpoint", "status"]
declareGauge presto_client_4xx_response_count,
"Number of received HTTP(s) 4xx client responses",
labels = ["endpoint", "status"]
declareGauge presto_client_5xx_response_count,
"Number of received HTTP(s) 5xx client responses",
labels = ["endpoint", "status"]
declareGauge presto_client_xxx_response_count,
"Number of received HTTP(s) unrecognized client responses",
declareGauge presto_client_response_status_count,
"Number of received client responses with specific status",
labels = ["endpoint", "status"]
declareGauge presto_client_connect_time,
"Time taken to establish connection with remote host",
Expand Down Expand Up @@ -535,19 +520,7 @@ template closeObjects(o1, o2, o3, o4: untyped): untyped =
when defined(metrics):
proc processStatusMetrics(ep: string, status: int) =
let sts = Base10.toString(uint64(status))
case status
of 100 .. 199:
presto_client_1xx_response_count.inc(1, @[ep, sts])
of 200 .. 299:
presto_client_2xx_response_count.inc(1, @[ep, sts])
of 300 .. 399:
presto_client_3xx_response_count.inc(1, @[ep, sts])
of 400 .. 499:
presto_client_4xx_response_count.inc(1, @[ep, sts])
of 500 .. 599:
presto_client_5xx_response_count.inc(1, @[ep, sts])
else:
presto_client_xxx_response_count.inc(1, @[ep, sts])
presto_client_response_status_count.inc(1, @[ep, sts])

proc processHttpResponseMetrics(response: HttpClientResponseRef,
endpoint: Opt[string],
Expand Down
34 changes: 3 additions & 31 deletions presto/serverprivate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,8 @@ import route, common, segpath, servercommon
when defined(metrics):
import metrics

declareGauge presto_server_1xx_response_count,
"Number of HTTP(s) 1xx server responses",
labels = ["endpoint", "status"]
declareGauge presto_server_2xx_response_count,
"Number of HTTP(s) 2xx server responses",
labels = ["endpoint", "status"]
declareGauge presto_server_3xx_response_count,
"Number of HTTP(s) 3xx server responses",
labels = ["endpoint", "status"]
declareGauge presto_server_4xx_response_count,
"Number of HTTP(s) 4xx server responses",
labels = ["endpoint", "status"]
declareGauge presto_server_5xx_response_count,
"Number of HTTP(s) 5xx server responses",
labels = ["endpoint", "status"]
declareGauge presto_server_xxx_response_count,
"Number of HTTP(s) unrecognized server responses",
declareGauge presto_server_response_status_count,
"Number of HTTP server responses with specific status",
labels = ["endpoint", "status"]
declareGauge presto_server_processed_request_count,
"Number of HTTP(s) processed requests"
Expand Down Expand Up @@ -84,20 +69,7 @@ when defined(metrics):
endpoint = $route.routePath
icode = toInt(code)
scode = Base10.toString(uint64(toInt(code)))

case icode
of 100 .. 199:
presto_server_1xx_response_count.inc(1, @[endpoint, scode])
of 200 .. 299:
presto_server_2xx_response_count.inc(1, @[endpoint, scode])
of 300 .. 399:
presto_server_3xx_response_count.inc(1, @[endpoint, scode])
of 400 .. 499:
presto_server_4xx_response_count.inc(1, @[endpoint, scode])
of 500 .. 599:
presto_server_5xx_response_count.inc(1, @[endpoint, scode])
else:
presto_server_xxx_response_count.inc(1, @[endpoint, scode])
presto_client_response_status_count.inc(1, @[endpoint, scode])

proc processStatusMetrics(route: RestRoute, code: HttpCode,
duration: Duration) =
Expand Down

0 comments on commit d1436cc

Please sign in to comment.