| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package scrapererror // import "go.opentelemetry.io/collector/scraper/scrapererror" |
| 5 |
|
| 6 |
import "errors" |
| 7 |
|
| 8 |
// PartialScrapeError is an error to represent |
| 9 |
// that a subset of data were failed to be scraped. |
| 10 |
type PartialScrapeError struct { |
| 11 |
error |
| 12 |
Failed int |
| 13 |
} |
| 14 |
|
| 15 |
// NewPartialScrapeError creates PartialScrapeError for failed data. |
| 16 |
// Use this error type only when a subset of data was failed to be scraped. |
| 17 |
func NewPartialScrapeError(err error, failed int) PartialScrapeError { |
| 18 |
return PartialScrapeError{ |
| 19 |
error: err, |
| 20 |
Failed: failed, |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
// IsPartialScrapeError checks if an error was wrapped with PartialScrapeError. |
| 25 |
func IsPartialScrapeError(err error) bool { |
| 26 |
var partialScrapeErr PartialScrapeError |
| 27 |
return errors.As(err, &partialScrapeErr) |
| 28 |
} |