Skip to content

Commit 221fb04

Browse files
adshmhOlshansk
andauthored
[Protocol][Shannon][Observability] Protocol shannon HTTP timeout metrics (#383)
## Summary Replace simple HTTP relay function with comprehensive HTTP client featuring request tracing and metrics collection ### Primary Changes: - Introduced new httpClientWithTracing struct with detailed HTTP request lifecycle monitoring and atomic counters for performance metrics - Replaced sendHttpRelay function with SendHTTPRelay method that includes comprehensive error categorization and request tracing - Added HTTP transport optimization with configurable connection pooling, timeout settings, and keep-alive configuration ### Secondary Changes: - Updated requestContext and Protocol structs to include httpClient field for centralized HTTP client management - Added detailed logging with timing breakdowns for DNS lookup, connection establishment, TLS handshake, and response times - Implemented graceful shutdown functionality with connection cleanup and statistics reporting ## Issue Missing details on HTTP timeouts when sending relay requests to endpoints. - Issue or PR: #{ISSUE_OR_PR_NUMBER} ## Type of change Select one or more from the following: - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## QoS Checklist ### E2E Validation & Tests - [ ] `make path_up` - [ ] `make test_e2e_evm_shannon` ### Observability - [ ] 1. `make path_up` - [ ] 2. Run the following E2E test: `make test_request__shannon_relay_util_100` - [ ] 3. View results in LocalNet's [PATH Relay Grafana Dashboard](http://localhost:3003/d/relays/path-service-requests) ## Sanity Checklist - [x] I have updated the GitHub Issue `assignees`, `reviewers`, `labels`, `project`, `iteration` and `milestone` - [ ] For docs, I have run `make docusaurus_start` - [ ] For code, I have run `make test_all` - [ ] For configurations, I have updated the documentation - [x] I added `TODO`s where applicable --------- Co-authored-by: Daniel Olshansky <[email protected]>
1 parent 2ea8ed4 commit 221fb04

File tree

7 files changed

+435
-95
lines changed

7 files changed

+435
-95
lines changed

observation/protocol/shannon.pb.go

Lines changed: 22 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/path/protocol/shannon.proto

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ message ShannonRequestError {
4545
enum ShannonEndpointErrorType {
4646
SHANNON_ENDPOINT_ERROR_UNSPECIFIED = 0;
4747
// endpoint internal error: not recognized.
48-
SHANNON_ENDPOINT_ERROR_INTERNAL = 1;
48+
// DEPRECATED: Use more specific error types below (HTTP_UNKNOWN, RAW_PAYLOAD_UNKNOWN, UNKNOWN)
49+
SHANNON_ENDPOINT_ERROR_INTERNAL = 1 [deprecated = true];
4950
// endpoint config error: e.g. DNS lookup error, TLS certificate error.
5051
SHANNON_ENDPOINT_ERROR_CONFIG = 2;
5152
// endpoint timeout on responding to relay request.
@@ -95,6 +96,13 @@ enum ShannonEndpointErrorType {
9596

9697
// RelayRequest was canceled by PATH intentionally.
9798
SHANNON_ENDPOINT_REQUEST_CANCELED_BY_PATH = 33;
99+
100+
// New error types for better classification (added without renumbering existing ones)
101+
// Error was recognized but specific classification failed.
102+
// Only general category: HTTP, Raw Payload, General, is known.
103+
SHANNON_ENDPOINT_ERROR_HTTP_UNKNOWN = 34;
104+
SHANNON_ENDPOINT_ERROR_RAW_PAYLOAD_UNKNOWN = 35;
105+
SHANNON_ENDPOINT_ERROR_UNKNOWN = 36;
98106
}
99107

100108
// ShannonSanctionType specifies the duration type for endpoint sanctions

protocol/shannon/context.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ type requestContext struct {
7070
// - Tracks RelayMinerError data from the current relay response for reporting.
7171
// - Set by trackRelayMinerError method and used when building observations.
7272
currentRelayMinerError *protocolobservations.ShannonRelayMinerError
73+
74+
// HTTP client used for sending relay requests to endpoints while also capturing various debug metrics
75+
httpClient *httpClientWithDebugMetrics
7376
}
7477

7578
// HandleServiceRequest:
@@ -244,7 +247,14 @@ func (rc *requestContext) sendRelay(payload protocol.Payload) (*servicetypes.Rel
244247
headers := buildHeaders(payload)
245248

246249
// Send the HTTP relay request
247-
httpRelayResponseBz, err := sendHttpRelay(ctxWithTimeout, rc.selectedEndpoint.url, signedRelayReq, headers)
250+
httpRelayResponseBz, err := rc.httpClient.SendHTTPRelay(
251+
ctxWithTimeout,
252+
hydratedLogger,
253+
rc.selectedEndpoint.url,
254+
signedRelayReq,
255+
headers,
256+
)
257+
248258
if err != nil {
249259
// Endpoint failed to respond before the timeout expires.
250260
// Wrap the net/http error with our classification error

0 commit comments

Comments
 (0)