-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
265 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ RUN apk add --no-cache ca-certificates | |
|
||
COPY --from=builder /app/indexer / | ||
ENTRYPOINT ["/indexer"] | ||
EXPOSE 2112 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package duneapi | ||
|
||
import ( | ||
"errors" | ||
"net/url" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
var metricSendBlockCount = promauto.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "dune_client", | ||
Name: "sent_block_total", | ||
Help: "Total number of blocks sent in requests", | ||
}, | ||
[]string{"status"}, | ||
) | ||
|
||
var metricSendBlockBatchSize = promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "dune_client", | ||
Name: "block_per_batch", | ||
Help: "Number of blocks per batch", | ||
Buckets: []float64{1, 2, 4, 8, 16, 32, 64, 128, 256}, | ||
}, | ||
[]string{"status"}, | ||
) | ||
|
||
var metricSendRequestsCount = promauto.NewCounterVec( | ||
|
||
prometheus.CounterOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "dune_client", | ||
Name: "send_requests_total", | ||
Help: "Number of send requests", | ||
}, | ||
[]string{"status"}, | ||
) | ||
|
||
var metricSendBlockBatchDurationMillis = promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "dune_client", | ||
Name: "send_block_batch_duration_millis", | ||
Help: "Duration of a send block batch request in milliseconds", | ||
Buckets: []float64{10, 25, 50, 100, 250, 500, 1000, 2000, 4000}, | ||
}, | ||
[]string{"status"}, | ||
) | ||
|
||
func observeSendBlocksRequest(status string, numberOfBlocks int, t0 time.Time) { | ||
metricSendBlockCount.WithLabelValues(status).Inc() | ||
metricSendBlockBatchSize.WithLabelValues(status).Observe(float64(numberOfBlocks)) | ||
metricSendBlockBatchDurationMillis.WithLabelValues(status).Observe(float64(time.Since(t0).Milliseconds())) | ||
metricSendRequestsCount.WithLabelValues(status).Add(float64(numberOfBlocks)) | ||
} | ||
|
||
func observeSendBlocksRequestCode(statusCode int, numberOfBlocks int, t0 time.Time) { | ||
observeSendBlocksRequest(strconv.Itoa(statusCode), numberOfBlocks, t0) | ||
} | ||
|
||
func observeSendBlocksRequestErr(err error, numberOfBlocks int, t0 time.Time) { | ||
observeSendBlocksRequest(errorToStatus(err), numberOfBlocks, t0) | ||
} | ||
|
||
func errorToStatus(err error) string { | ||
status := "unknown_error" | ||
var urlErr *url.Error | ||
if errors.As(err, &urlErr) { | ||
if urlErr.Timeout() { | ||
status = "timeout" | ||
} else { | ||
status = "connection_refused" | ||
} | ||
} | ||
return status | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package jsonrpc | ||
|
||
import ( | ||
"errors" | ||
"net/url" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
var rpcRequestCount = promauto.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "rpc_client", | ||
Name: "request_total", | ||
Help: "Total number of RPC node requests", | ||
}, | ||
[]string{"status", "method"}, | ||
) | ||
|
||
var rpcRequestDurationMillis = promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: "node_indexer", | ||
Subsystem: "rpc_client", | ||
Name: "request_duration_millis", | ||
Help: "Duration of RPC node requests in milliseconds", | ||
Buckets: []float64{10, 25, 50, 100, 250, 500, 1000, 2000, 4000}, | ||
}, | ||
[]string{"status", "method"}, | ||
) | ||
|
||
func observeRPCRequest(status string, method string, t0 time.Time) { | ||
rpcRequestCount.WithLabelValues(status, method).Inc() | ||
rpcRequestDurationMillis.WithLabelValues(status, method).Observe(float64(time.Since(t0).Milliseconds())) | ||
} | ||
|
||
func observeRPCRequestCode(statusCode int, method string, t0 time.Time) { | ||
observeRPCRequest(strconv.Itoa(statusCode), method, t0) | ||
} | ||
|
||
func observeRPCRequestErr(err error, method string, t0 time.Time) { | ||
observeRPCRequest(errorToStatus(err), method, t0) | ||
} | ||
|
||
func errorToStatus(err error) string { | ||
status := "unknown_error" | ||
var urlErr *url.Error | ||
if errors.As(err, &urlErr) { | ||
if urlErr.Timeout() { | ||
status = "timeout" | ||
} else { | ||
status = "connection_refused" | ||
} | ||
} | ||
return status | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.