globalerror

package
v0.0.0-...-cb24dfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapGRPCErrorWithContextError

func WrapGRPCErrorWithContextError(ctx context.Context, err error) error

WrapGRPCErrorWithContextError checks if the given error is a gRPC error corresponding to a standard golang context error, and if it is, wraps the former with the latter. If the given error isn't a gRPC error, or it doesn't correspond to a standard golang context error, the original error is returned.

Types

type ErrorWithStatus

type ErrorWithStatus struct {
	UnderlyingErr error
	Status        *status.Status
	// contains filtered or unexported fields
}

ErrorWithStatus is used for wrapping errors returned by ingester. Errors returned by ingester should be gRPC errors, but the errors produced by both gogo/status and grpc/status packages do not keep the semantics of the underlying error, which is sometimes needed. For example, the logging middleware needs to know whether an error should be logged, sampled or ignored. Errors of type ErrorWithStatus are valid gRPC errors that could be parsed by both gogo/status and grpc/status packages, but which preserve the original error semantics.

func WrapErrorWithGRPCStatus

func WrapErrorWithGRPCStatus(originalErr error, errCode codes.Code, errDetails *mimirpb.ErrorDetails) ErrorWithStatus

WrapErrorWithGRPCStatus wraps the given error with a gRPC status, which is built out of the given parameters: the gRPC status' code and details are passed as parameters, while its message corresponds to the original error. The resulting error is of type ErrorWithStatus.

func (ErrorWithStatus) Equals

func (e ErrorWithStatus) Equals(err error) bool

Equals returns true if the given error and this error are equal, i.e., if they are both of type ErrorWithStatus, if their underlying statuses have the same code, messages, and if both have either no details, or exactly one detail of type mimirpb.ErrorDetails, which are equal too.

func (ErrorWithStatus) Err

func (e ErrorWithStatus) Err() error

Err returns an immutable error representing this ErrorWithStatus. Returns nil if UnderlyingError is nil or Status.Code() is OK. The resulting error is of type error, and it can be parsed to the corresponding gRPC status by both gogo/status and grpc/status packages.

func (ErrorWithStatus) Error

func (e ErrorWithStatus) Error() string

func (ErrorWithStatus) GRPCStatus

func (e ErrorWithStatus) GRPCStatus() *grpcstatus.Status

GRPCStatus with a *grpcstatus.Status as output is needed for a correct execution of grpc/status.FromError().

func (ErrorWithStatus) Unwrap

func (e ErrorWithStatus) Unwrap() []error

type ID

type ID string
const (
	MissingMetricName                     ID = "missing-metric-name"
	InvalidMetricName                     ID = "metric-name-invalid"
	MaxLabelNamesPerSeries                ID = "max-label-names-per-series"
	MaxLabelNamesPerInfoSeries            ID = "max-label-names-per-info-series"
	MaxNativeHistogramBuckets             ID = "max-native-histogram-buckets"
	NotReducibleNativeHistogram           ID = "not-reducible-native-histogram"
	InvalidSchemaNativeHistogram          ID = "invalid-native-histogram-schema"
	SeriesInvalidLabel                    ID = "label-invalid"
	SeriesInvalidLabelValue               ID = "label-value-invalid"
	SeriesLabelNameTooLong                ID = "label-name-too-long"
	SeriesLabelValueTooLong               ID = "label-value-too-long"
	SeriesWithDuplicateLabelNames         ID = "duplicate-label-names"
	SeriesLabelsNotSorted                 ID = "labels-not-sorted"
	SampleTooFarInFuture                  ID = "too-far-in-future"
	SampleTooFarInPast                    ID = "too-far-in-past"
	MaxSeriesPerMetric                    ID = "max-series-per-metric"
	MaxMetadataPerMetric                  ID = "max-metadata-per-metric"
	MaxSeriesPerUser                      ID = "max-series-per-user"
	MaxMetadataPerUser                    ID = "max-metadata-per-user"
	MaxChunksPerQuery                     ID = "max-chunks-per-query"
	MaxSeriesPerQuery                     ID = "max-series-per-query"
	MaxChunkBytesPerQuery                 ID = "max-chunks-bytes-per-query"
	MaxEstimatedChunksPerQuery            ID = "max-estimated-chunks-per-query"
	MaxEstimatedMemoryConsumptionPerQuery ID = "max-estimated-memory-consumption-per-query"

	DistributorMaxIngestionRate             ID = "distributor-max-ingestion-rate"
	DistributorMaxInflightPushRequests      ID = "distributor-max-inflight-push-requests"
	DistributorMaxInflightPushRequestsBytes ID = "distributor-max-inflight-push-requests-bytes"

	IngesterMaxIngestionRate             ID = "ingester-max-ingestion-rate"
	IngesterMaxTenants                   ID = "ingester-max-tenants"
	IngesterMaxInMemorySeries            ID = "ingester-max-series"
	IngesterMaxInflightPushRequests      ID = "ingester-max-inflight-push-requests"
	IngesterMaxInflightPushRequestsBytes ID = "ingester-max-inflight-push-requests-bytes"

	ExemplarLabelsMissing    ID = "exemplar-labels-missing"
	ExemplarLabelsTooLong    ID = "exemplar-labels-too-long"
	ExemplarTimestampInvalid ID = "exemplar-timestamp-invalid"

	MetricMetadataMissingMetricName ID = "metadata-missing-metric-name"
	MetricMetadataMetricNameTooLong ID = "metric-name-too-long"
	MetricMetadataHelpTooLong       ID = "help-too-long" // unused, left here to prevent reuse for different purpose
	MetricMetadataUnitTooLong       ID = "unit-too-long"

	MaxQueryLength              ID = "max-query-length"
	MaxTotalQueryLength         ID = "max-total-query-length"
	MaxQueryExpressionSizeBytes ID = "max-query-expression-size-bytes"
	RequestRateLimited          ID = "tenant-max-request-rate"
	IngestionRateLimited        ID = "tenant-max-ingestion-rate"
	TooManyHAClusters           ID = "tenant-too-many-ha-clusters"
	QueryBlocked                ID = "query-blocked"

	SampleTimestampTooOld    ID = "sample-timestamp-too-old"
	SampleOutOfOrder         ID = "sample-out-of-order"
	SampleDuplicateTimestamp ID = "sample-duplicate-timestamp"
	ExemplarSeriesMissing    ID = "exemplar-series-missing"
	ExemplarTooFarInFuture   ID = "exemplar-too-far-in-future"
	ExemplarTooFarInPast     ID = "exemplar-too-far-in-past"

	StoreConsistencyCheckFailed ID = "store-consistency-check-failed"
	BucketIndexTooOld           ID = "bucket-index-too-old"

	DistributorMaxWriteMessageSize         ID = "distributor-max-write-message-size"
	DistributorMaxOTLPRequestSize          ID = "distributor-max-otlp-request-size"
	DistributorMaxWriteRequestDataItemSize ID = "distributor-max-write-request-data-item-size"

	// Map Prometheus TSDB native histogram validation errors to Mimir errors.
	// E.g. histogram.ErrHistogramCountNotBigEnough -> NativeHistogramCountNotBigEnough
	NativeHistogramCountMismatch        ID = "native-histogram-count-mismatch"
	NativeHistogramCountNotBigEnough    ID = "native-histogram-count-not-big-enough"
	NativeHistogramNegativeBucketCount  ID = "native-histogram-negative-bucket-count"
	NativeHistogramSpanNegativeOffset   ID = "native-histogram-span-negative-offset"
	NativeHistogramSpansBucketsMismatch ID = "native-histogram-spans-buckets-mismatch"
	NativeHistogramOOODisabled          ID = "native-histogram-ooo-disabled"

	// Alertmanager errors
	AlertmanagerMaxGrafanaConfigSize ID = "alertmanager-max-grafana-config-size"
	AlertmanagerMaxGrafanaStateSize  ID = "alertmanager-max-grafana-state-size"
)

This block defines error IDs exposed to the final user. These IDs are expected to be *immutable*, so don't rename them over time.

func (ID) Error

func (id ID) Error() string

Error implements error.

func (ID) LabelValue

func (id ID) LabelValue() string

LabelValue returns the error ID converted to a form suitable for use as a Prometheus label value.

func (ID) Message

func (id ID) Message(msg string) string

Message returns the provided msg, appending the error id.

func (ID) MessageWithPerInstanceLimitConfig

func (id ID) MessageWithPerInstanceLimitConfig(msg, flag string, addFlags ...string) string

MessageWithPerInstanceLimitConfig returns the provided msg, appending the error id and a suggestion on which configuration flag(s) to use to change the per-instance limit.

func (ID) MessageWithPerTenantLimitConfig

func (id ID) MessageWithPerTenantLimitConfig(msg, flag string, addFlags ...string) string

MessageWithPerTenantLimitConfig returns the provided msg, appending the error id and a suggestion on which configuration flag(s) to use to change the per-tenant limit.

func (ID) MessageWithStrategyAndPerTenantLimitConfig

func (id ID) MessageWithStrategyAndPerTenantLimitConfig(msg, strategy, flag string, addFlags ...string) string

MessageWithStrategyAndPerTenantLimitConfig returns the provided msg, appending the error id and a suggestion on which strategy to follow to try not hitting the limit, plus which configuration flag(s) to otherwise change the per-tenant limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL