Skip to content

Commit 5bf5373

Browse files
committed
chore(deps): deprecated dependency to opentracing
* fixes #365 This PR deprecates the WithOpenTracing runtime option, in favor the WithOpenTelemetry option. The WithOpenTracing method remains exposed, so programs that build with that one don't break, but options are ignored and it returns an opentelemetry-enabled transport. A new independent is introduced to provide backward-compatibility to users who are not able to transition to opentelemetry. Technically, the runtime repo now moves to a multi-modules mono-repo structure, similar to github.com/go-openapi/swag. The necessary CI changes are applied. Signed-off-by: Frederic BIDON <[email protected]>
1 parent 476a4c4 commit 5bf5373

File tree

14 files changed

+336
-27
lines changed

14 files changed

+336
-27
lines changed

.github/workflows/go-test.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ jobs:
2020
go-version: stable
2121
check-latest: true
2222
cache: true
23+
cache-dependency-path: '**/go.sum'
2324
- name: golangci-lint
2425
uses: golangci/golangci-lint-action@v8
2526
with:
2627
version: latest
2728
only-new-issues: true
2829
skip-cache: true
2930

30-
test:
31-
name: Unit tests
31+
module-test:
32+
name: Run unit tests on all modules in this repo
3233
runs-on: ${{ matrix.os }}
3334

3435
strategy:
@@ -37,21 +38,48 @@ jobs:
3738
go_version: ['oldstable', 'stable']
3839

3940
steps:
41+
- uses: actions/checkout@v5
4042
- uses: actions/setup-go@v6
4143
with:
4244
go-version: '${{ matrix.go_version }}'
4345
check-latest: true
4446
cache: true
45-
46-
- uses: actions/checkout@v5
47+
cache-dependency-path: '**/go.sum'
4748
- name: Run unit tests
4849
shell: bash
49-
run: go test -v -race -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" -covermode=atomic -coverpkg=$(go list)/... ./...
50+
env:
51+
# *.coverage.* pattern is automatically detected by codecov
52+
COVER_PROFILE: 'all_modules.coverage.${{ matrix.os }}.${{ matrix.go_version }}.out'
53+
run: |
54+
# when go1.25 becomes the oldstable, we may replace this bash with "go work test"
55+
declare -a ALL_MODULES
56+
BASH_MAJOR=$(echo $BASH_VERSION|cut -d'.' -f1)
57+
if [[ "${BASH_MAJOR}" -ge 4 ]] ; then
58+
mapfile ALL_MODULES < <(go list -f '{{.Dir}}/...' -m)
59+
else
60+
# for older bash versions, e.g. on macOS runner. This fallback will eventually disappear.
61+
while read line ; do
62+
ALL_MODULES+=("${line}")
63+
done < <(go list -f '{{.Dir}}/...' -m)
64+
fi
65+
echo "::notice title=Modules found::${ALL_MODULES[@]}"
66+
67+
# with go.work file enabled, go test recognizes sub-modules and collects all packages to be covered
68+
# without specifying -coverpkg.
69+
go test -v -race -coverprofile="${COVER_PROFILE}" -covermode=atomic ${ALL_MODULES[@]}
5070
5171
- name: Upload coverage to codecov
5272
uses: codecov/codecov-action@v5
5373
with:
54-
files: './coverage-${{ matrix.os }}.${{ matrix.go_version }}.out'
5574
flags: '${{ matrix.go_version }}-${{ matrix.os }}'
5675
fail_ci_if_error: false
5776
verbose: true
77+
78+
test:
79+
needs: [ module-test ]
80+
name: Test
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Tests complete
84+
run: |
85+
echo "All tests completed"

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ linters:
1515
- gocognit
1616
- godot
1717
- godox
18+
- gomoddirectives # moved to mono-repo, multi-modules, so replace directives are needed
1819
- gosmopolitan
1920
- inamedparam
20-
- intrange # disabled while < go1.22
21+
#- intrange # disabled while < go1.22
2122
- ireturn
2223
- lll
2324
- musttag
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module github.com/go-openapi/runtime/client-middleware/opentracing
2+
3+
require (
4+
github.com/go-openapi/runtime v0.28.0
5+
github.com/go-openapi/strfmt v0.23.0
6+
github.com/opentracing/opentracing-go v1.2.0
7+
github.com/stretchr/testify v1.11.1
8+
)
9+
10+
require (
11+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
12+
github.com/davecgh/go-spew v1.1.1 // indirect
13+
github.com/go-logr/logr v1.4.3 // indirect
14+
github.com/go-logr/stdr v1.2.2 // indirect
15+
github.com/go-openapi/analysis v0.23.0 // indirect
16+
github.com/go-openapi/errors v0.22.2 // indirect
17+
github.com/go-openapi/jsonpointer v0.22.0 // indirect
18+
github.com/go-openapi/jsonreference v0.21.1 // indirect
19+
github.com/go-openapi/loads v0.22.0 // indirect
20+
github.com/go-openapi/spec v0.21.0 // indirect
21+
github.com/go-openapi/swag v0.24.1 // indirect
22+
github.com/go-openapi/swag/cmdutils v0.24.0 // indirect
23+
github.com/go-openapi/swag/conv v0.24.0 // indirect
24+
github.com/go-openapi/swag/fileutils v0.24.0 // indirect
25+
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
26+
github.com/go-openapi/swag/jsonutils v0.24.0 // indirect
27+
github.com/go-openapi/swag/loading v0.24.0 // indirect
28+
github.com/go-openapi/swag/mangling v0.24.0 // indirect
29+
github.com/go-openapi/swag/netutils v0.24.0 // indirect
30+
github.com/go-openapi/swag/stringutils v0.24.0 // indirect
31+
github.com/go-openapi/swag/typeutils v0.24.0 // indirect
32+
github.com/go-openapi/swag/yamlutils v0.24.0 // indirect
33+
github.com/go-openapi/validate v0.24.0 // indirect
34+
github.com/google/uuid v1.6.0 // indirect
35+
github.com/josharian/intern v1.0.0 // indirect
36+
github.com/mailru/easyjson v0.9.0 // indirect
37+
github.com/mitchellh/mapstructure v1.5.0 // indirect
38+
github.com/oklog/ulid v1.3.1 // indirect
39+
github.com/pmezard/go-difflib v1.0.0 // indirect
40+
go.mongodb.org/mongo-driver v1.17.4 // indirect
41+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
42+
go.opentelemetry.io/otel v1.38.0 // indirect
43+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
44+
go.opentelemetry.io/otel/trace v1.38.0 // indirect
45+
golang.org/x/sync v0.17.0 // indirect
46+
gopkg.in/yaml.v3 v3.0.1 // indirect
47+
)
48+
49+
replace github.com/go-openapi/runtime => ../..
50+
51+
go 1.24.0
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
2+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
3+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
7+
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
8+
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
9+
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
10+
github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC03zFCU=
11+
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
12+
github.com/go-openapi/errors v0.22.2 h1:rdxhzcBUazEcGccKqbY1Y7NS8FDcMyIRr0934jrYnZg=
13+
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
14+
github.com/go-openapi/jsonreference v0.21.1 h1:bSKrcl8819zKiOgxkbVNRUBIr6Wwj9KYrDbMjRs0cDA=
15+
github.com/go-openapi/loads v0.22.0 h1:ECPGd4jX1U6NApCGG1We+uEozOAvXvJSF4nnwHZ8Aco=
16+
github.com/go-openapi/loads v0.22.0/go.mod h1:yLsaTCS92mnSAZX5WWoxszLj0u+Ojl+Zs5Stn1oF+rs=
17+
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
18+
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
19+
github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c=
20+
github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4=
21+
github.com/go-openapi/swag v0.24.1 h1:DPdYTZKo6AQCRqzwr/kGkxJzHhpKxZ9i/oX0zag+MF8=
22+
github.com/go-openapi/swag/cmdutils v0.24.0 h1:KlRCffHwXFI6E5MV9n8o8zBRElpY4uK4yWyAMWETo9I=
23+
github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik=
24+
github.com/go-openapi/swag/fileutils v0.24.0 h1:U9pCpqp4RUytnD689Ek/N1d2N/a//XCeqoH508H5oak=
25+
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
26+
github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts=
27+
github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc=
28+
github.com/go-openapi/swag/mangling v0.24.0 h1:PGOQpViCOUroIeak/Uj/sjGAq9LADS3mOyjznmHy2pk=
29+
github.com/go-openapi/swag/netutils v0.24.0 h1:Bz02HRjYv8046Ycg/w80q3g9QCWeIqTvlyOjQPDjD8w=
30+
github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM=
31+
github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw=
32+
github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c=
33+
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
34+
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
35+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
36+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
37+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
38+
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
39+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
40+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
41+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
42+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
43+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
44+
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
45+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
46+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
47+
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
48+
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
49+
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
50+
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
51+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
52+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
53+
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
54+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
55+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
56+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
57+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
58+
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
59+
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
60+
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
61+
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
62+
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
63+
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
64+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
65+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
66+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
67+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
68+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
69+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
70+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

client/opentracing.go renamed to client-middleware/opentracing/opentracing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package client
1+
package opentracing
22

33
import (
44
"fmt"
@@ -27,7 +27,7 @@ func newOpenTracingTransport(transport runtime.ClientTransport, host string, opt
2727
}
2828
}
2929

30-
func (t *tracingTransport) Submit(op *runtime.ClientOperation) (interface{}, error) {
30+
func (t *tracingTransport) Submit(op *runtime.ClientOperation) (any, error) {
3131
if op.Context == nil {
3232
return t.transport.Submit(op)
3333
}
@@ -47,7 +47,7 @@ func (t *tracingTransport) Submit(op *runtime.ClientOperation) (interface{}, err
4747
return params.WriteToRequest(req, reg)
4848
})
4949

50-
op.Reader = runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
50+
op.Reader = runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
5151
if span != nil {
5252
code := response.Code()
5353
ext.HTTPStatusCode.Set(span, uint16(code)) //nolint:gosec // safe to convert regular HTTP codes, no adverse impact other than a garbled trace when converting a code larger than 65535

client/opentracing_test.go renamed to client-middleware/opentracing/opentracing_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package client
1+
package opentracing
22

33
import (
44
"bytes"
55
"context"
66
"io"
77
"testing"
88

9+
"github.com/go-openapi/runtime/client"
910
"github.com/go-openapi/strfmt"
1011
"github.com/opentracing/opentracing-go"
1112
"github.com/opentracing/opentracing-go/ext"
@@ -39,10 +40,10 @@ type mockRuntime struct {
3940
req runtime.TestClientRequest
4041
}
4142

42-
func (m *mockRuntime) Submit(operation *runtime.ClientOperation) (interface{}, error) {
43+
func (m *mockRuntime) Submit(operation *runtime.ClientOperation) (any, error) {
4344
_ = operation.Params.WriteToRequest(&m.req, nil)
4445
_, _ = operation.Reader.ReadResponse(&tres{}, nil)
45-
return map[string]interface{}{}, nil
46+
return map[string]any{}, nil
4647
}
4748

4849
func testOperation(ctx context.Context) *runtime.ClientOperation {
@@ -52,14 +53,14 @@ func testOperation(ctx context.Context) *runtime.ClientOperation {
5253
PathPattern: "/kubernetes-clusters/{cluster_id}",
5354
ProducesMediaTypes: []string{"application/json"},
5455
ConsumesMediaTypes: []string{"application/json"},
55-
Schemes: []string{schemeHTTPS},
56-
Reader: runtime.ClientResponseReaderFunc(func(runtime.ClientResponse, runtime.Consumer) (interface{}, error) {
56+
Schemes: []string{"https"},
57+
Reader: runtime.ClientResponseReaderFunc(func(runtime.ClientResponse, runtime.Consumer) (any, error) {
5758
return nil, nil
5859
}),
5960
Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
6061
return nil
6162
}),
62-
AuthInfo: PassThroughAuth,
63+
AuthInfo: client.PassThroughAuth,
6364
Context: ctx,
6465
}
6566
}
@@ -107,7 +108,7 @@ func testSubmit(t *testing.T, operation *runtime.ClientOperation, tracer *mocktr
107108
if expectedSpans == 1 {
108109
span := tracer.FinishedSpans()[0]
109110
assert.Equal(t, "getCluster", span.OperationName)
110-
assert.Equal(t, map[string]interface{}{
111+
assert.Equal(t, map[string]any{
111112
"component": "go-openapi",
112113
"http.method": "GET",
113114
"http.path": "/kubernetes-clusters/{cluster_id}",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package opentracing
2+
3+
import (
4+
"github.com/go-openapi/runtime"
5+
"github.com/go-openapi/runtime/client"
6+
opentracing "github.com/opentracing/opentracing-go"
7+
)
8+
9+
// WithOpenTracing adds opentracing support to the provided runtime.
10+
// A new client span is created for each request.
11+
//
12+
// If the context of the client operation does not contain an active span, no span is created.
13+
// The provided opts are applied to each spans - for example to add global tags.
14+
//
15+
// This method is provided to continue supporting users of [github.com/go-openapi/runtime] who
16+
// still rely on opentracing and have not been able to transition to opentelemetry yet.
17+
func WithOpenTracing(r *client.Runtime, opts ...opentracing.StartSpanOption) runtime.ClientTransport {
18+
return newOpenTracingTransport(r, r.Host, opts)
19+
}

client/mock_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package client
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"io"
7+
8+
"github.com/go-openapi/runtime"
9+
"github.com/go-openapi/strfmt"
10+
)
11+
12+
type mockRuntime struct {
13+
req runtime.TestClientRequest
14+
}
15+
16+
func (m *mockRuntime) Submit(operation *runtime.ClientOperation) (any, error) {
17+
_ = operation.Params.WriteToRequest(&m.req, nil)
18+
_, _ = operation.Reader.ReadResponse(&tres{}, nil)
19+
return map[string]any{}, nil
20+
}
21+
22+
type tres struct {
23+
}
24+
25+
func (r tres) Code() int {
26+
return 490
27+
}
28+
func (r tres) Message() string {
29+
return "the message"
30+
}
31+
func (r tres) GetHeader(_ string) string {
32+
return "the header"
33+
}
34+
func (r tres) GetHeaders(_ string) []string {
35+
return []string{"the headers", "the headers2"}
36+
}
37+
func (r tres) Body() io.ReadCloser {
38+
return io.NopCloser(bytes.NewBufferString("the content"))
39+
}
40+
41+
func testOperation(ctx context.Context) *runtime.ClientOperation {
42+
return &runtime.ClientOperation{
43+
ID: "getCluster",
44+
Method: "GET",
45+
PathPattern: "/kubernetes-clusters/{cluster_id}",
46+
ProducesMediaTypes: []string{"application/json"},
47+
ConsumesMediaTypes: []string{"application/json"},
48+
Schemes: []string{"https"},
49+
Reader: runtime.ClientResponseReaderFunc(func(runtime.ClientResponse, runtime.Consumer) (any, error) {
50+
return nil, nil
51+
}),
52+
Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error {
53+
return nil
54+
}),
55+
AuthInfo: PassThroughAuth,
56+
Context: ctx,
57+
}
58+
}

client/opentelemetry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func assertOpenTelemetrySubmit(t *testing.T, operation *runtime.ClientOperation,
118118

119119
span := spans[0]
120120
assert.Equal(t, "getCluster", span.Name)
121-
assert.Equal(t, "go-openapi", span.InstrumentationLibrary.Name)
121+
assert.Equal(t, "go-openapi", span.InstrumentationScope.Name)
122122
assert.Equal(t, codes.Error, span.Status.Code)
123123
assert.Equal(t, []attribute.KeyValue{
124124
attribute.String("net.peer.name", "remote_host"),

0 commit comments

Comments
 (0)