mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-10-08 05:23:18 +01:00
build(makefile): re-enable the embedlit go fix modernizer
This commit is contained in:
15
Makefile
15
Makefile
@@ -219,20 +219,17 @@ lint-prettier: ## Lint non-Golang codebase
|
|||||||
lint-todo: ## Find TODOs in Golang codebase
|
lint-todo: ## Find TODOs in Golang codebase
|
||||||
golangci-lint run --no-config --default=none --enable godox
|
golangci-lint run --no-config --default=none --enable godox
|
||||||
|
|
||||||
# TODO: restore a plain "go fix ./..." once both modernizers stop rewriting this
|
# TODO: restore a plain "go fix ./..." once the errorsastype modernizer stops
|
||||||
# codebase into code that does not compile. Re-check by dropping a flag and
|
# rewriting this codebase into code that does not compile. Re-check by dropping
|
||||||
# running "make fmt && make lint". Removing an analyzer upstream makes go fix
|
# the flag and running "make fmt && make lint". Removing the analyzer upstream
|
||||||
# fail with "flag provided but not defined", so this cannot rot silently.
|
# makes go fix fail with "flag provided but not defined", so this cannot rot
|
||||||
# embedlit folds a post-literal field assignment into a literal that already
|
# silently.
|
||||||
# sets that key, producing a duplicate field name (cmd/gotenberg.go). Fixed in
|
|
||||||
# Go 1.27.1, so drop that flag once the toolchain moves past 1.27.0.
|
|
||||||
# See https://github.com/golang/go/issues/81101.
|
|
||||||
# errorsastype rewrites errors.As to errors.AsType[T] without checking that T
|
# errorsastype rewrites errors.As to errors.AsType[T] without checking that T
|
||||||
# satisfies error, which breaks on api.HttpError since it does not embed
|
# satisfies error, which breaks on api.HttpError since it does not embed
|
||||||
# error. Still broken as of Go 1.27.1.
|
# error. Still broken as of Go 1.27.1.
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt: ## Format Golang codebase and "optimize" the dependencies
|
fmt: ## Format Golang codebase and "optimize" the dependencies
|
||||||
go fix -embedlit=false -errorsastype=false ./...
|
go fix -errorsastype=false ./...
|
||||||
golangci-lint fmt
|
golangci-lint fmt
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
|
|||||||
@@ -201,17 +201,13 @@ func TestNewServerRecordMetrics(t *testing.T) {
|
|||||||
server.RecordMetrics(t.Context(), semconv.ServerMetricData{
|
server.RecordMetrics(t.Context(), semconv.ServerMetricData{
|
||||||
ServerName: "stuff",
|
ServerName: "stuff",
|
||||||
ResponseSize: 200,
|
ResponseSize: 200,
|
||||||
MetricAttributes: semconv.MetricAttributes{
|
Req: req,
|
||||||
Req: req,
|
StatusCode: 301,
|
||||||
StatusCode: 301,
|
AdditionalAttributes: []attribute.KeyValue{
|
||||||
AdditionalAttributes: []attribute.KeyValue{
|
attribute.String("key", "value"),
|
||||||
attribute.String("key", "value"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
MetricData: semconv.MetricData{
|
|
||||||
RequestSize: 100,
|
|
||||||
ElapsedTime: 300,
|
|
||||||
},
|
},
|
||||||
|
RequestSize: 100,
|
||||||
|
ElapsedTime: 300,
|
||||||
})
|
})
|
||||||
|
|
||||||
rm := metricdata.ResourceMetrics{}
|
rm := metricdata.ResourceMetrics{}
|
||||||
|
|||||||
@@ -355,17 +355,13 @@ func telemetryMiddleware(logger *slog.Logger, serverName, correlationIdHeader st
|
|||||||
}
|
}
|
||||||
|
|
||||||
semconvSrv.RecordMetrics(ctx, semconvutil.ServerMetricData{
|
semconvSrv.RecordMetrics(ctx, semconvutil.ServerMetricData{
|
||||||
ServerName: serverName,
|
ServerName: serverName,
|
||||||
ResponseSize: c.Response().Size,
|
ResponseSize: c.Response().Size,
|
||||||
MetricAttributes: semconvutil.MetricAttributes{
|
Req: request,
|
||||||
Req: request,
|
StatusCode: status,
|
||||||
StatusCode: status,
|
AdditionalAttributes: additionalAttributes,
|
||||||
AdditionalAttributes: additionalAttributes,
|
RequestSize: request.ContentLength,
|
||||||
},
|
ElapsedTime: float64(time.Since(startTime)) / float64(time.Millisecond),
|
||||||
MetricData: semconvutil.MetricData{
|
|
||||||
RequestSize: request.ContentLength,
|
|
||||||
ElapsedTime: float64(time.Since(startTime)) / float64(time.Millisecond),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user