Documentation
¶
Index ¶
- Constants
- func DiscardBaggageErrors() gin.HandlerFunc
- func DocEndpoint(config config.Config, control Controller, router *gin.Engine)
- func InstancesEndpoints(_ config.Config, control Controller, router *gin.Engine)
- func Start(ctx context.Context, config config.Config, control Controller) (err error)
- type Controller
- type ErrorResponse
Constants ¶
const ServiceName = "import-deploy"
ServiceName identifies this service to the outside: it names the traces in the collector and the tracer that produces them.
Variables ¶
This section is empty.
Functions ¶
func DiscardBaggageErrors ¶ added in v0.2.0
func DiscardBaggageErrors() gin.HandlerFunc
DiscardBaggageErrors takes the errors the OpenTelemetry handler reported off the request and logs them instead.
otelx reports a baggage value it cannot carry -- one holding a space, a comma or a non-ASCII character -- with gin's c.Error. gin_mw.ErrorHandler then turns anything in c.Errors into a response: it forces a 500 where the status was below 400, and appends the error text to the body. A user whose Keycloak username holds a space would therefore get a 500 on every DELETE and a corrupted JSON body on every GET, for a log annotation that failed.
This handler has to sit immediately after the OpenTelemetry handler. otelx adds those errors before it calls c.Next(), so at this point in the chain nothing else can have added one, which is what makes clearing the slice safe. Moved further down, it would discard a real handler's error.
The proper fix belongs in gin-middleware, which should not use c.Error for something that is not a request error.
func DocEndpoint ¶ added in v0.0.28
func DocEndpoint(config config.Config, control Controller, router *gin.Engine)
func InstancesEndpoints ¶
func InstancesEndpoints(_ config.Config, control Controller, router *gin.Engine)
Types ¶
type Controller ¶
type Controller interface {
ListInstances(ctx context.Context, jwt jwt.Token, limit int64, offset int64, sort string, asc bool, search string, includeGenerated bool, ids []string) (results []model.Instance, err error, errCode int)
ReadInstance(ctx context.Context, id string, jwt jwt.Token) (result model.Instance, err error, errCode int)
CreateInstance(ctx context.Context, instance model.Instance, jwt jwt.Token) (result model.Instance, err error, code int)
SetInstance(ctx context.Context, importType model.Instance, jwt jwt.Token) (err error, code int)
DeleteInstance(ctx context.Context, id string, jwt jwt.Token) (err error, errCode int)
CountInstances(ctx context.Context, jwt jwt.Token, search string, includeGenerated bool) (count int64, err error, errCode int)
}
The ctx of every method is the one of the incoming request: it carries the trace and the baggage the OpenTelemetry middleware put on it.
type ErrorResponse ¶ added in v0.0.28
type ErrorResponse string