Skip to content

Commit 0628cdf

Browse files
committed
chore(go): upgraded to g1.24
* upgraded go-opentelemetry packages Signed-off-by: Frederic BIDON <[email protected]>
1 parent 6912bd1 commit 0628cdf

File tree

8 files changed

+99
-52
lines changed

8 files changed

+99
-52
lines changed

.github/workflows/go-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
strategy:
3535
matrix:
3636
os: [ ubuntu-latest, macos-latest, windows-latest ]
37-
go_version: ['oldstable', 'stable', '1.20']
37+
go_version: ['oldstable', 'stable']
3838

3939
steps:
4040
- uses: actions/setup-go@v6

client/opentelemetry.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
"go.opentelemetry.io/otel/attribute"
1212
"go.opentelemetry.io/otel/codes"
1313
"go.opentelemetry.io/otel/propagation"
14-
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
15-
"go.opentelemetry.io/otel/semconv/v1.17.0/httpconv"
14+
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
1615
"go.opentelemetry.io/otel/trace"
1716
)
1817

@@ -133,10 +132,13 @@ func (t *openTelemetryTransport) Submit(op *runtime.ClientOperation) (interface{
133132
if span != nil {
134133
statusCode := response.Code()
135134
// NOTE: this is replaced by semconv.HTTPResponseStatusCode in semconv v1.21
136-
span.SetAttributes(semconv.HTTPStatusCode(statusCode))
135+
span.SetAttributes(semconv.HTTPResponseStatusCode(statusCode))
137136
// NOTE: the conversion from HTTP status code to trace code is no longer available with
138137
// semconv v1.21
139-
span.SetStatus(httpconv.ServerStatus(statusCode))
138+
const minHTTPStatusIsError = 400
139+
if statusCode >= minHTTPStatusIsError {
140+
span.SetStatus(codes.Error, http.StatusText(statusCode))
141+
}
140142
}
141143

142144
return reader.ReadResponse(response, consumer)
@@ -173,7 +175,7 @@ func (t *openTelemetryTransport) newOpenTelemetrySpan(op *runtime.ClientOperatio
173175
span.SetAttributes(
174176
attribute.String("net.peer.name", t.host),
175177
attribute.String(string(semconv.HTTPRouteKey), op.PathPattern),
176-
attribute.String(string(semconv.HTTPMethodKey), op.Method),
178+
attribute.String(string(semconv.HTTPRequestMethodKey), op.Method),
177179
attribute.String("span.kind", trace.SpanKindClient.String()),
178180
attribute.String("http.scheme", scheme),
179181
)

client/opentelemetry_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ func assertOpenTelemetrySubmit(t *testing.T, operation *runtime.ClientOperation,
123123
assert.Equal(t, []attribute.KeyValue{
124124
attribute.String("net.peer.name", "remote_host"),
125125
attribute.String("http.route", "/kubernetes-clusters/{cluster_id}"),
126-
attribute.String("http.method", http.MethodGet),
126+
attribute.String("http.request.method", http.MethodGet),
127127
attribute.String("span.kind", trace.SpanKindClient.String()),
128128
attribute.String("http.scheme", schemeHTTPS),
129129
// NOTE: this becomes http.response.status_code with semconv v1.21
130-
attribute.Int("http.status_code", 490),
130+
attribute.Int("http.response.status_code", 490),
131131
}, span.Attributes)
132132
}

go.mod

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,45 @@ require (
77
github.com/go-openapi/loads v0.22.0
88
github.com/go-openapi/spec v0.21.0
99
github.com/go-openapi/strfmt v0.23.0
10-
github.com/go-openapi/swag v0.23.1
10+
github.com/go-openapi/swag v0.24.1
1111
github.com/go-openapi/validate v0.24.0
1212
github.com/opentracing/opentracing-go v1.2.0
1313
github.com/stretchr/testify v1.11.1
14-
go.opentelemetry.io/otel v1.24.0
15-
go.opentelemetry.io/otel/sdk v1.24.0
16-
go.opentelemetry.io/otel/trace v1.24.0
17-
golang.org/x/sync v0.11.0
14+
go.opentelemetry.io/otel v1.38.0
15+
go.opentelemetry.io/otel/sdk v1.38.0
16+
go.opentelemetry.io/otel/trace v1.38.0
17+
golang.org/x/sync v0.17.0
1818
gopkg.in/yaml.v3 v3.0.1
1919
)
2020

2121
require (
2222
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
2323
github.com/davecgh/go-spew v1.1.1 // indirect
24-
github.com/go-logr/logr v1.4.1 // indirect
24+
github.com/go-logr/logr v1.4.3 // indirect
2525
github.com/go-logr/stdr v1.2.2 // indirect
26-
github.com/go-openapi/jsonpointer v0.21.0 // indirect
27-
github.com/go-openapi/jsonreference v0.21.0 // indirect
26+
github.com/go-openapi/jsonpointer v0.22.0 // indirect
27+
github.com/go-openapi/jsonreference v0.21.1 // indirect
28+
github.com/go-openapi/swag/cmdutils v0.24.0 // indirect
29+
github.com/go-openapi/swag/conv v0.24.0 // indirect
30+
github.com/go-openapi/swag/fileutils v0.24.0 // indirect
31+
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
32+
github.com/go-openapi/swag/jsonutils v0.24.0 // indirect
33+
github.com/go-openapi/swag/loading v0.24.0 // indirect
34+
github.com/go-openapi/swag/mangling v0.24.0 // indirect
35+
github.com/go-openapi/swag/netutils v0.24.0 // indirect
36+
github.com/go-openapi/swag/stringutils v0.24.0 // indirect
37+
github.com/go-openapi/swag/typeutils v0.24.0 // indirect
38+
github.com/go-openapi/swag/yamlutils v0.24.0 // indirect
2839
github.com/google/uuid v1.6.0 // indirect
2940
github.com/josharian/intern v1.0.0 // indirect
3041
github.com/mailru/easyjson v0.9.0 // indirect
3142
github.com/mitchellh/mapstructure v1.5.0 // indirect
3243
github.com/oklog/ulid v1.3.1 // indirect
3344
github.com/pmezard/go-difflib v1.0.0 // indirect
34-
go.mongodb.org/mongo-driver v1.14.0 // indirect
35-
go.opentelemetry.io/otel/metric v1.24.0 // indirect
36-
golang.org/x/sys v0.17.0 // indirect
45+
go.mongodb.org/mongo-driver v1.17.4 // indirect
46+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
47+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
48+
golang.org/x/sys v0.35.0 // indirect
3749
)
3850

39-
go 1.20
51+
go 1.24.0

go.sum

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,60 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
66
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
77
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
88
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
9-
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
10-
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
9+
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
10+
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
1111
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
1212
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
1313
github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU=
1414
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
1515
github.com/go-openapi/errors v0.22.2 h1:rdxhzcBUazEcGccKqbY1Y7NS8FDcMyIRr0934jrYnZg=
1616
github.com/go-openapi/errors v0.22.2/go.mod h1:+n/5UdIqdVnLIJ6Q9Se8HNGUXYaY6CN8ImWzfi/Gzp0=
17-
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
18-
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
19-
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
20-
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
17+
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
18+
github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU=
19+
github.com/go-openapi/jsonreference v0.21.1 h1:bSKrcl8819zKiOgxkbVNRUBIr6Wwj9KYrDbMjRs0cDA=
20+
github.com/go-openapi/jsonreference v0.21.1/go.mod h1:PWs8rO4xxTUqKGu+lEvvCxD5k2X7QYkKAepJyCmSTT8=
2121
github.com/go-openapi/loads v0.22.0 h1:ECPGd4jX1U6NApCGG1We+uEozOAvXvJSF4nnwHZ8Aco=
2222
github.com/go-openapi/loads v0.22.0/go.mod h1:yLsaTCS92mnSAZX5WWoxszLj0u+Ojl+Zs5Stn1oF+rs=
2323
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
2424
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
2525
github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c=
2626
github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4=
27-
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
28-
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
27+
github.com/go-openapi/swag v0.24.1 h1:DPdYTZKo6AQCRqzwr/kGkxJzHhpKxZ9i/oX0zag+MF8=
28+
github.com/go-openapi/swag v0.24.1/go.mod h1:sm8I3lCPlspsBBwUm1t5oZeWZS0s7m/A+Psg0ooRU0A=
29+
github.com/go-openapi/swag/cmdutils v0.24.0 h1:KlRCffHwXFI6E5MV9n8o8zBRElpY4uK4yWyAMWETo9I=
30+
github.com/go-openapi/swag/cmdutils v0.24.0/go.mod h1:uxib2FAeQMByyHomTlsP8h1TtPd54Msu2ZDU/H5Vuf8=
31+
github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik=
32+
github.com/go-openapi/swag/conv v0.24.0/go.mod h1:jbn140mZd7EW2g8a8Y5bwm8/Wy1slLySQQ0ND6DPc2c=
33+
github.com/go-openapi/swag/fileutils v0.24.0 h1:U9pCpqp4RUytnD689Ek/N1d2N/a//XCeqoH508H5oak=
34+
github.com/go-openapi/swag/fileutils v0.24.0/go.mod h1:3SCrCSBHyP1/N+3oErQ1gP+OX1GV2QYFSnrTbzwli90=
35+
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
36+
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
37+
github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts=
38+
github.com/go-openapi/swag/jsonutils v0.24.0/go.mod h1:vBowZtF5Z4DDApIoxcIVfR8v0l9oq5PpYRUuteVu6f0=
39+
github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc=
40+
github.com/go-openapi/swag/loading v0.24.0/go.mod h1:gShCN4woKZYIxPxbfbyHgjXAhO61m88tmjy0lp/LkJk=
41+
github.com/go-openapi/swag/mangling v0.24.0 h1:PGOQpViCOUroIeak/Uj/sjGAq9LADS3mOyjznmHy2pk=
42+
github.com/go-openapi/swag/mangling v0.24.0/go.mod h1:Jm5Go9LHkycsz0wfoaBDkdc4CkpuSnIEf62brzyCbhc=
43+
github.com/go-openapi/swag/netutils v0.24.0 h1:Bz02HRjYv8046Ycg/w80q3g9QCWeIqTvlyOjQPDjD8w=
44+
github.com/go-openapi/swag/netutils v0.24.0/go.mod h1:WRgiHcYTnx+IqfMCtu0hy9oOaPR0HnPbmArSRN1SkZM=
45+
github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM=
46+
github.com/go-openapi/swag/stringutils v0.24.0/go.mod h1:5nUXB4xA0kw2df5PRipZDslPJgJut+NjL7D25zPZ/4w=
47+
github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw=
48+
github.com/go-openapi/swag/typeutils v0.24.0/go.mod h1:q8C3Kmk/vh2VhpCLaoR2MVWOGP8y7Jc8l82qCTd1DYI=
49+
github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c=
50+
github.com/go-openapi/swag/yamlutils v0.24.0/go.mod h1:DpKv5aYuaGm/sULePoeiG8uwMpZSfReo1HR3Ik0yaG8=
2951
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
3052
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
31-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
53+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
54+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
3255
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3356
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3457
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
3558
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
3659
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
60+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3761
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
62+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3863
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
3964
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
4065
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -45,26 +70,34 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
4570
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
4671
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4772
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
48-
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
73+
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
74+
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
4975
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5076
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
5177
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
5278
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
53-
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
54-
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
55-
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
56-
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
57-
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
58-
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
59-
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
60-
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
61-
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
62-
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
63-
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
64-
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
65-
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
66-
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
79+
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
80+
go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
81+
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
82+
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
83+
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
84+
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
85+
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
86+
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
87+
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
88+
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
89+
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
90+
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
91+
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
92+
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
93+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
94+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
95+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
96+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
97+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
98+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
6799
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
68100
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
101+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
69102
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
70103
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

middleware/context.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func NewRoutableContext(spec *loads.Document, routableAPI RoutableAPI, routes Ro
219219
func NewRoutableContextWithAnalyzedSpec(spec *loads.Document, an *analysis.Spec, routableAPI RoutableAPI, routes Router) *Context {
220220
// Either there are no spec doc and analysis, or both of them.
221221
if (spec != nil || an != nil) && (spec == nil || an == nil) {
222-
panic(errors.New(http.StatusInternalServerError, "routable context requires either both spec doc and analysis, or none of them"))
222+
panic(fmt.Errorf("%d: %s", http.StatusInternalServerError, "routable context requires either both spec doc and analysis, or none of them"))
223223
}
224224

225225
return &Context{
@@ -486,7 +486,7 @@ func (c *Context) Authorize(request *http.Request, route *MatchedRoute) (interfa
486486
return nil, nil, err
487487
}
488488

489-
return nil, nil, errors.New(http.StatusForbidden, err.Error())
489+
return nil, nil, errors.New(http.StatusForbidden, "%v", err)
490490
}
491491
}
492492

@@ -552,7 +552,7 @@ func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []st
552552
prods := c.api.ProducersFor(normalizeOffers([]string{c.api.DefaultProduces()}))
553553
pr, ok := prods[c.api.DefaultProduces()]
554554
if !ok {
555-
panic(errors.New(http.StatusInternalServerError, cantFindProducer(format)))
555+
panic(fmt.Errorf("%d: %s", http.StatusInternalServerError, cantFindProducer(format)))
556556
}
557557
prod = pr
558558
}
@@ -585,7 +585,7 @@ func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []st
585585
producers := c.api.ProducersFor(normalizeOffers(offers))
586586
prod, ok := producers[format]
587587
if !ok {
588-
panic(errors.New(http.StatusInternalServerError, cantFindProducer(format)))
588+
panic(fmt.Errorf("%d: %s", http.StatusInternalServerError, cantFindProducer(format)))
589589
}
590590
if err := prod.Produce(rw, data); err != nil {
591591
panic(err) // let the recovery middleware deal with this
@@ -606,7 +606,7 @@ func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []st
606606
prods := c.api.ProducersFor(normalizeOffers([]string{c.api.DefaultProduces()}))
607607
pr, ok := prods[c.api.DefaultProduces()]
608608
if !ok {
609-
panic(errors.New(http.StatusInternalServerError, cantFindProducer(format)))
609+
panic(fmt.Errorf("%d: %s", http.StatusInternalServerError, cantFindProducer(format)))
610610
}
611611
prod = pr
612612
}
@@ -617,7 +617,7 @@ func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []st
617617
return
618618
}
619619

620-
c.api.ServeErrorFor(route.Operation.ID)(rw, r, errors.New(http.StatusInternalServerError, "can't produce response"))
620+
c.api.ServeErrorFor(route.Operation.ID)(rw, r, fmt.Errorf("%d: %s", http.StatusInternalServerError, "can't produce response"))
621621
}
622622

623623
// APIHandlerSwaggerUI returns a handler to serve the API.

middleware/context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func TestContextAuthorize_WithAuthorizer(t *testing.T) {
437437
p, reqWithCtx, err = ctx.Authorize(request, ri)
438438
require.Error(t, err)
439439
ae, ok := err.(apierrors.Error)
440-
assert.True(t, ok)
440+
require.Truef(t, ok, "expected an apierrors.Error, but got %T", err)
441441
assert.Equal(t, http.StatusForbidden, int(ae.Code()))
442442
assert.Nil(t, p)
443443
assert.Nil(t, reqWithCtx)

middleware/parameter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (p *untypedParamBinder) Bind(request *http.Request, routeParams RouteParams
185185
target.Set(reflect.Indirect(newValue))
186186
return nil
187187
default:
188-
return errors.New(http.StatusInternalServerError, fmt.Sprintf("invalid parameter location %q", p.parameter.In))
188+
return fmt.Errorf("%d: invalid parameter location %q", http.StatusInternalServerError, p.parameter.In)
189189
}
190190
}
191191

0 commit comments

Comments
 (0)