Skip to content

Commit

Permalink
adding a swagger for the metrics endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Feb 26, 2024
1 parent cc93a6f commit 02a60dd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion api/accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"math/big"
"net/http"
"strconv"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/gorilla/mux"
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func New(

// to serve api docs
if enableMetrics {
router.PathPrefix("/metrics").Handler(telemetry.Handler())
router.PathPrefix("/node/metrics").Handler(telemetry.Handler())
}

// to serve api doc and swagger-ui
Expand Down
52 changes: 27 additions & 25 deletions api/doc/thor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,33 @@ paths:
schema:
$ref: '#/components/schemas/GetPeersResponse'

/node/metrics:
get:
tags:
- Node
summary: Retrieve Prometheus metrics
description: |
This endpoint allows clients to retrieve Prometheus metrics.
responses:
'200':
description: Prometheus metrics response
content:
text/plain:
schema:
type: string
example: |
# HELP http_requests_total The total number of HTTP requests.
# TYPE http_requests_total counter
http_requests_total{method="GET",handler="/foo"} 100
http_requests_total{method="POST",handler="/bar"} 200
# HELP http_request_duration_seconds The duration of HTTP requests.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.1"} 10
http_request_duration_seconds_bucket{le="1"} 20
http_request_duration_seconds_bucket{le="10"} 30
http_request_duration_seconds_sum 123.45
http_request_duration_seconds_count 60
/subscriptions/block:
get:
tags:
Expand Down Expand Up @@ -736,31 +763,6 @@ paths:
type: string
example: 'Invalid address'

/metrics:
get:
summary: Retrieve Prometheus metrics
description: |
This endpoint allows clients to retrieve Prometheus metrics.
responses:
'200':
description: Prometheus metrics response
content:
text/plain:
schema:
type: string
example: |
# HELP http_requests_total The total number of HTTP requests.
# TYPE http_requests_total counter
http_requests_total{method="GET",handler="/foo"} 100
http_requests_total{method="POST",handler="/bar"} 200
# HELP http_request_duration_seconds The duration of HTTP requests.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.1"} 10
http_request_duration_seconds_bucket{le="1"} 20
http_request_duration_seconds_bucket{le="10"} 30
http_request_duration_seconds_sum 123.45
http_request_duration_seconds_count 60
components:
schemas:
GetAccountResponse:
Expand Down

0 comments on commit 02a60dd

Please sign in to comment.