Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

feat: add more error strings/types to capture "other" #73

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions metrics/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var (

// HandleFailureEvent is called when a query _or_ retrieval fails
func (m *Metrics) HandleFailureEvent(ctx context.Context, id types.RetrievalID, phase types.Phase, storageProviderID string, details interface{}) {

detailsObj, ok := details.(map[string]interface{})
if !ok {
return
Expand Down Expand Up @@ -167,7 +166,8 @@ func (m *Metrics) HandleAggregatedEvent(ctx context.Context,
indexerCandidates int64,
indexerFiltered int64,
attempts map[string]Attempt,
protocolSucceeded string) {
protocolSucceeded string,
) {
m.totalRequestCount.Add(ctx, 1)
failureCount := 0
var lowestTTFB time.Duration
Expand Down Expand Up @@ -246,7 +246,7 @@ func (m *Metrics) HandleAggregatedEvent(ctx context.Context,
}

func (m *Metrics) getMatchingErrorMetric(ctx context.Context, msg string) (instrument.Int64Counter, bool) {
var errorMetricMatches = []struct {
errorMetricMatches := []struct {
substr string
metric instrument.Int64Counter
}{
Expand All @@ -257,6 +257,7 @@ func (m *Metrics) getMatchingErrorMetric(ctx context.Context, msg string) (instr
{"miner is not accepting online retrieval deals", m.retrievalErrorNoOnlineCount},
{"unconfirmed block transfer", m.retrievalErrorUnconfirmedCount},
{"timeout after ", m.retrievalErrorTimeoutCount},
{"retrieval timed out after ", m.retrievalErrorTimeoutCount},
{"there is no unsealed piece containing payload cid", m.retrievalErrorNoUnsealedCount},
{"getting pieces for cid", m.retrievalErrorDAGStoreCount},
{"graphsync request failed to complete: request failed - unknown reason", m.retrievalErrorGraphsyncCount},
Expand All @@ -268,6 +269,7 @@ func (m *Metrics) getMatchingErrorMetric(ctx context.Context, msg string) (instr
{"unexpected block in CAR", m.retrievalErrorHTTPUnexpectedBlock},
{"missing block in CAR", m.retrievalErrorHTTPMissingBlock},
{"malformed CAR", m.retrievalErrorHTTPMalformedCar},
{"data transfer failed: datatransfer error: data transfer channel ", m.retrievalErrorDatatransferCount},
}

for _, match := range errorMetricMatches {
Expand All @@ -278,12 +280,14 @@ func (m *Metrics) getMatchingErrorMetric(ctx context.Context, msg string) (instr

return nil, false
}

func protocolFromSpID(storageProviderId string) string {
if storageProviderId == types.BitswapIndentifier {
return ProtocolBitswap
}
return ProtocolGraphsync
}

func protocolFromMulticodecString(multicodecCodeString string) string {
switch multicodecCodeString {
case multicodec.TransportBitswap.String():
Expand Down
6 changes: 6 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ func (m *Metrics) Start() error {
); err != nil {
return err
}
if m.retrievalErrorDatatransferCount, err = meter.Int64Counter(meterName+"/retrieval_error_datatransfer_total",
instrument.WithDescription("The number of retrieval errors due to datatransfer requests that errored"),
); err != nil {
return err
}
if m.retrievalErrorFailedToDialCount, err = meter.Int64Counter(meterName+"/retrieval_error_failed_to_dial_total",
instrument.WithDescription("The number of retrieval errors because we could not connected to the provider"),
); err != nil {
Expand Down Expand Up @@ -404,6 +409,7 @@ type stats struct {
retrievalErrorNoUnsealedCount instrument.Int64Counter
retrievalErrorDAGStoreCount instrument.Int64Counter
retrievalErrorGraphsyncCount instrument.Int64Counter
retrievalErrorDatatransferCount instrument.Int64Counter
retrievalErrorFailedToDialCount instrument.Int64Counter
retrievalErrorHTTPRemoteRequestNotFound instrument.Int64Counter
retrievalErrorHTTPRemoteRequestGone instrument.Int64Counter
Expand Down