You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-23 22:34:47 +02:00
Go documents the following regex pattern for identifying generated code: ^// Code generated .* DO NOT EDIT\.$ This convention is used go APIs and tooling. References: https://pkg.go.dev/go/ast#IsGenerated https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source Co-authored-by: Damien Mathieu <42@dmathieu.com>
57 lines
1.5 KiB
Cheetah
57 lines
1.5 KiB
Cheetah
// Code generated by gotmpl. DO NOT MODIFY.
|
|
// source: internal/shared/otlp/partialsuccess.go
|
|
|
|
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package internal
|
|
|
|
import "fmt"
|
|
|
|
// PartialSuccess represents the underlying error for all handling
|
|
// OTLP partial success messages. Use `errors.Is(err,
|
|
// PartialSuccess{})` to test whether an error passed to the OTel
|
|
// error handler belongs to this category.
|
|
type PartialSuccess struct {
|
|
ErrorMessage string
|
|
RejectedItems int64
|
|
RejectedKind string
|
|
}
|
|
|
|
var _ error = PartialSuccess{}
|
|
|
|
// Error implements the error interface.
|
|
func (ps PartialSuccess) Error() string {
|
|
msg := ps.ErrorMessage
|
|
if msg == "" {
|
|
msg = "empty message"
|
|
}
|
|
return fmt.Sprintf("OTLP partial success: %s (%d %s rejected)", msg, ps.RejectedItems, ps.RejectedKind)
|
|
}
|
|
|
|
// Is supports the errors.Is() interface.
|
|
func (ps PartialSuccess) Is(err error) bool {
|
|
_, ok := err.(PartialSuccess)
|
|
return ok
|
|
}
|
|
|
|
// TracePartialSuccessError returns an error describing a partial success
|
|
// response for the trace signal.
|
|
func TracePartialSuccessError(itemsRejected int64, errorMessage string) error {
|
|
return PartialSuccess{
|
|
ErrorMessage: errorMessage,
|
|
RejectedItems: itemsRejected,
|
|
RejectedKind: "spans",
|
|
}
|
|
}
|
|
|
|
// MetricPartialSuccessError returns an error describing a partial success
|
|
// response for the metric signal.
|
|
func MetricPartialSuccessError(itemsRejected int64, errorMessage string) error {
|
|
return PartialSuccess{
|
|
ErrorMessage: errorMessage,
|
|
RejectedItems: itemsRejected,
|
|
RejectedKind: "metric data points",
|
|
}
|
|
}
|