diff --git a/metrics/events.go b/metrics/events.go index 72b1b91..4259369 100644 --- a/metrics/events.go +++ b/metrics/events.go @@ -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 @@ -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 @@ -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 }{ @@ -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}, @@ -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 { @@ -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(): diff --git a/metrics/metrics.go b/metrics/metrics.go index 6b19a74..d47d2a7 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -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 { @@ -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