Skip to content

Commit ac3906a

Browse files
committed
feat: upgrade go agent to v2
go.elastic.co/apm v1 has been deprecated for a while. Update the dependency to v2.
1 parent 2b2e8d0 commit ac3906a

File tree

25 files changed

+78
-294
lines changed

25 files changed

+78
-294
lines changed

NOTICE.txt

+20-231
Large diffs are not rendered by default.

go.mod

+4-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ require (
5757
github.com/stretchr/testify v1.9.0
5858
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
5959
github.com/winlabs/gowin32 v0.0.0-20221003142512-0d265587d3c9
60-
go.elastic.co/apm/module/apmgorilla v1.15.0
60+
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0
61+
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0
62+
go.elastic.co/apm/v2 v2.6.0
6163
go.elastic.co/ecszap v1.0.1
6264
go.elastic.co/go-licence-detector v0.5.0
6365
go.uber.org/zap v1.27.0
@@ -222,10 +224,8 @@ require (
222224
github.com/tklauser/numcpus v0.6.1 // indirect
223225
github.com/valyala/fastjson v1.6.4 // indirect
224226
github.com/yusufpapurcu/wmi v1.2.4 // indirect
225-
go.elastic.co/apm/module/apmhttp v1.15.0 // indirect
226227
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 // indirect
227228
go.elastic.co/apm/module/apmzap/v2 v2.6.0 // indirect
228-
go.elastic.co/apm/v2 v2.6.0 // indirect
229229
go.elastic.co/fastjson v1.3.0 // indirect
230230
go.opencensus.io v0.24.0 // indirect
231231
go.opentelemetry.io/collector v0.102.1 // indirect
@@ -271,7 +271,6 @@ require (
271271
gonum.org/v1/gonum v0.15.0 // indirect
272272
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
273273
google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 // indirect
274-
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 // indirect
275274
gopkg.in/inf.v0 v0.9.1 // indirect
276275
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
277276
howett.net/plist v1.0.1 // indirect
@@ -284,8 +283,7 @@ require (
284283
require (
285284
github.com/hashicorp/go-version v1.7.0 // indirect
286285
github.com/json-iterator/go v1.1.12 // indirect
287-
go.elastic.co/apm v1.15.0
288-
go.elastic.co/apm/module/apmgrpc v1.15.0
286+
go.elastic.co/apm v1.15.0 // indirect
289287
k8s.io/klog/v2 v2.110.1 // indirect
290288
)
291289

go.sum

+6-14
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,8 @@ github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97Dwqy
11361136
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
11371137
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
11381138
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
1139-
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
11401139
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
11411140
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
1142-
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
11431141
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
11441142
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
11451143
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
@@ -1924,13 +1922,11 @@ go.elastic.co/apm/module/apmelasticsearch v1.10.0 h1:5Vq4uDpoS6kfTTBuNrEd3KJ4kwv
19241922
go.elastic.co/apm/module/apmelasticsearch v1.10.0/go.mod h1:lwoaGDfZzfb9e6TXd3h8/KNmLAONOas7o5NLVNmv8Xk=
19251923
go.elastic.co/apm/module/apmelasticsearch/v2 v2.6.0 h1:ukMcwyMaDXsS1dRK2qRYXT2AsfwaUy74TOOYCqkWJow=
19261924
go.elastic.co/apm/module/apmelasticsearch/v2 v2.6.0/go.mod h1:YpfiTTrqX5LB/CKBwX89oDCBAxuLJTFv40gcfxJyehM=
1927-
go.elastic.co/apm/module/apmgorilla v1.15.0 h1:1yTAksffgaFXYEIwlLRiQnxLfy3p3RtpDw8HDupIJfY=
1928-
go.elastic.co/apm/module/apmgorilla v1.15.0/go.mod h1:+23mZudYvZ9VgxCQjseLo9EF5gkKEr0KSQBupw+rzP8=
1929-
go.elastic.co/apm/module/apmgrpc v1.15.0 h1:Z7h58uuMJUoYXK6INFunlcGEXZQ18QKAhPh6NFYDNHE=
1930-
go.elastic.co/apm/module/apmgrpc v1.15.0/go.mod h1:IEbTGJzY5Xx737PkHDT3bbzh9syovK+IfAlckJsUgPE=
1925+
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0 h1:vXMZPNFss4a9146sIuT4zxQemVpQjNUDIIS9RMOr9PE=
1926+
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0/go.mod h1:w3/W4oDZPWBye0McuIpM7d5xSQ1WoFnMmgmEIzCsxIk=
1927+
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0 h1:0HPYGtjjS6wUE/f7Pw7L4R7IvgptGlXY8qMKFifFZj0=
1928+
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0/go.mod h1:96P3OJkfJe3ZzkCHmFofu5VOWa4CAPRWyUiCt4NgWkk=
19311929
go.elastic.co/apm/module/apmhttp v1.10.0/go.mod h1:Y4timwcJ8sQWbWpcw3Y7Mat1OssNpGhpwyfUnpqIDew=
1932-
go.elastic.co/apm/module/apmhttp v1.15.0 h1:Le/DhI0Cqpr9wG/NIGOkbz7+rOMqJrfE4MRG6q/+leU=
1933-
go.elastic.co/apm/module/apmhttp v1.15.0/go.mod h1:NruY6Jq8ALLzWUVUQ7t4wIzn+onKoiP5woJJdTV7GMg=
19341930
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 h1:s8UeNFQmVBCNd4eoz7KDD9rEFhQC0HeUFXz3z9gpAmQ=
19351931
go.elastic.co/apm/module/apmhttp/v2 v2.6.0/go.mod h1:D0GLppLuI0Ddwvtl595GUxRgn6Z8L5KaDFVMv2H3GK0=
19361932
go.elastic.co/apm/module/apmzap/v2 v2.6.0 h1:R/iVORzGu3F9uM43iEVHD0nwiRo59O0bIXdayKsgayQ=
@@ -2600,7 +2596,6 @@ golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
26002596
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
26012597
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
26022598
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
2603-
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
26042599
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
26052600
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
26062601
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -2789,7 +2784,6 @@ google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7Fc
27892784
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
27902785
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
27912786
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
2792-
google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
27932787
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
27942788
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
27952789
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
@@ -2880,7 +2874,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.
28802874
google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 h1:Q2RxlXqh1cgzzUgV261vBO2jI5R/3DD1J2pM0nI4NhU=
28812875
google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
28822876
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
2883-
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
28842877
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
28852878
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
28862879
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@@ -2927,8 +2920,8 @@ google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5v
29272920
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
29282921
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
29292922
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
2930-
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 h1:r16FSFCMhn7+LU8CzbtAIKppYeU6NUPJVdvXeIqVIq8=
2931-
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767/go.mod h1:wKDg0brwMZpaizQ1i7IzYcJjH1TmbJudYdnQC9+J+LE=
2923+
google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 h1:kNDwMX0e15RGrBh4L1jfhVxyddRi6J/y8Gg+dcZr+S8=
2924+
google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37/go.mod h1:GGFp5xqHkVYOZBc9//ZnLinno7HB6j97fG1nL3au94o=
29322925
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
29332926
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
29342927
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -3011,7 +3004,6 @@ gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
30113004
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
30123005
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
30133006
helm.sh/helm/v3 v3.11.2/go.mod h1:Hw+09mfpDiRRKAgAIZlFkPSeOkvv7Acl5McBvQyNPVw=
3014-
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
30153007
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
30163008
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
30173009
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/pkg/agent/application/application.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/elastic/elastic-agent/pkg/limits"
1414
"github.com/elastic/elastic-agent/version"
1515

16-
"go.elastic.co/apm"
16+
"go.elastic.co/apm/v2"
1717

1818
"github.com/elastic/elastic-agent-libs/logp"
1919

internal/pkg/agent/application/coordinator/coordinator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/hashicorp/go-multierror"
1616

17-
"go.elastic.co/apm"
17+
"go.elastic.co/apm/v2"
1818
"gopkg.in/yaml.v2"
1919

2020
"github.com/elastic/elastic-agent-client/v7/pkg/client"

internal/pkg/agent/application/coordinator/coordinator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/stretchr/testify/assert"
2121
"github.com/stretchr/testify/require"
2222

23-
"go.elastic.co/apm/apmtest"
23+
"go.elastic.co/apm/v2/apmtest"
2424

2525
"github.com/elastic/elastic-agent-libs/logp"
2626

internal/pkg/agent/application/dispatcher/dispatcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"strings"
1212
"time"
1313

14-
"go.elastic.co/apm"
14+
"go.elastic.co/apm/v2"
1515

1616
"github.com/elastic/elastic-agent/internal/pkg/agent/application/actions"
1717
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"

internal/pkg/agent/application/monitoring/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"strings"
1414

1515
"github.com/gorilla/mux"
16-
"go.elastic.co/apm"
17-
"go.elastic.co/apm/module/apmgorilla"
16+
"go.elastic.co/apm/v2"
17+
"go.elastic.co/apm/module/apmgorilla/v2"
1818

1919
"github.com/elastic/elastic-agent-libs/api"
2020
"github.com/elastic/elastic-agent-libs/monitoring"

internal/pkg/agent/application/upgrade/artifact/download/composed/downloader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"context"
99

1010
"github.com/hashicorp/go-multierror"
11-
"go.elastic.co/apm"
11+
"go.elastic.co/apm/v2"
1212

1313
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
1414
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact/download"

internal/pkg/agent/application/upgrade/artifact/download/fs/downloader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"os"
1212
"path/filepath"
1313

14-
"go.elastic.co/apm"
14+
"go.elastic.co/apm/v2"
1515

1616
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
1717
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"

internal/pkg/agent/application/upgrade/step_download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/cenkalti/backoff/v4"
1616

17-
"go.elastic.co/apm"
17+
"go.elastic.co/apm/v2"
1818

1919
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
2020
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"

internal/pkg/agent/application/upgrade/upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"time"
1818

1919
"github.com/otiai10/copy"
20-
"go.elastic.co/apm"
20+
"go.elastic.co/apm/v2"
2121

2222
"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
2323
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"

internal/pkg/agent/cmd/enroll_cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"strings"
1616
"time"
1717

18-
"go.elastic.co/apm"
18+
"go.elastic.co/apm/v2"
1919
"gopkg.in/yaml.v2"
2020

2121
"github.com/elastic/elastic-agent-libs/transport/httpcommon"

internal/pkg/agent/cmd/run.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"syscall"
1616
"time"
1717

18-
"go.elastic.co/apm"
19-
apmtransport "go.elastic.co/apm/transport"
18+
"go.elastic.co/apm/v2"
19+
apmtransport "go.elastic.co/apm/v2/transport"
2020
"gopkg.in/yaml.v2"
2121

2222
"github.com/spf13/cobra"
@@ -580,7 +580,7 @@ func tryDelayEnroll(ctx context.Context, logger *logger.Logger, cfg *configurati
580580
}
581581

582582
func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig) (*apm.Tracer, error) {
583-
apm.DefaultTracer.Close()
583+
apm.DefaultTracer().Close()
584584

585585
if !mcfg.Enabled || !mcfg.MonitorTraces {
586586
return nil, nil
@@ -610,10 +610,7 @@ func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig)
610610
defer os.Unsetenv(envCACert)
611611
}
612612

613-
ts, err := apmtransport.NewHTTPTransport()
614-
if err != nil {
615-
return nil, err
616-
}
613+
opts := apmtransport.HTTPTransportOptions{}
617614

618615
if len(cfg.Hosts) > 0 {
619616
hosts := make([]*url.URL, 0, len(cfg.Hosts))
@@ -624,12 +621,17 @@ func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig)
624621
}
625622
hosts = append(hosts, u)
626623
}
627-
ts.SetServerURL(hosts...)
624+
opts.ServerURLs = hosts
628625
}
629626
if cfg.APIKey != "" {
630-
ts.SetAPIKey(cfg.APIKey)
627+
opts.APIKey = cfg.APIKey
631628
} else {
632-
ts.SetSecretToken(cfg.SecretToken)
629+
opts.SecretToken = cfg.SecretToken
630+
}
631+
632+
ts, err := apmtransport.NewHTTPTransport(opts)
633+
if err != nil {
634+
return nil, err
633635
}
634636

635637
return apm.NewTracerOptions(apm.TracerOptions{

internal/pkg/basecmd/version/cmd_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"
16-
"go.elastic.co/apm/apmtest"
16+
"go.elastic.co/apm/v2/apmtest"
1717
"gopkg.in/yaml.v2"
1818

1919
"github.com/elastic/elastic-agent-libs/logp"

internal/pkg/fleetapi/ack_cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"fmt"
1212
"io"
1313

14-
"go.elastic.co/apm"
14+
"go.elastic.co/apm/v2"
1515

1616
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
1717
"github.com/elastic/elastic-agent/internal/pkg/fleetapi/client"

internal/pkg/fleetapi/acker/fleet/fleet_acker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"time"
1212

13-
"go.elastic.co/apm"
13+
"go.elastic.co/apm/v2"
1414

1515
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
1616
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"

internal/pkg/fleetapi/acker/lazy/lazy_acker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"context"
99
"net/http"
1010

11-
"go.elastic.co/apm"
11+
"go.elastic.co/apm/v2"
1212

1313
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
1414
"github.com/elastic/elastic-agent/pkg/core/logger"

pkg/component/fake/component/comp/apm.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"github.com/elastic/elastic-agent-client/v7/pkg/client"
1717
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
1818

19-
"go.elastic.co/apm"
20-
apmtransport "go.elastic.co/apm/transport"
19+
"go.elastic.co/apm/v2"
20+
apmtransport "go.elastic.co/apm/v2/transport"
2121

2222
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
2323
)
@@ -133,10 +133,7 @@ func (ats *apmTracesSender) createNewTracer(cfg *proto.APMConfig) (*apm.Tracer,
133133
defer os.Unsetenv(envGlobalLabels)
134134
}
135135

136-
ts, err := apmtransport.NewHTTPTransport()
137-
if err != nil {
138-
return nil, err
139-
}
136+
opts := apmtransport.HTTPTransportOptions{}
140137

141138
if len(cfg.Elastic.Hosts) > 0 {
142139
hosts := make([]*url.URL, 0, len(cfg.Elastic.Hosts))
@@ -147,13 +144,19 @@ func (ats *apmTracesSender) createNewTracer(cfg *proto.APMConfig) (*apm.Tracer,
147144
}
148145
hosts = append(hosts, u)
149146
}
150-
ts.SetServerURL(hosts...)
147+
opts.ServerURLs = hosts
151148
}
152149
if cfg.Elastic.ApiKey != "" {
153-
ts.SetAPIKey(cfg.Elastic.ApiKey)
150+
opts.APIKey = cfg.Elastic.ApiKey
154151
} else if cfg.Elastic.SecretToken != "" {
155-
ts.SetSecretToken(cfg.Elastic.SecretToken)
152+
opts.SecretToken = cfg.Elastic.SecretToken
153+
}
154+
155+
ts, err := apmtransport.NewHTTPTransport(opts)
156+
if err != nil {
157+
return nil, err
156158
}
159+
157160
return apm.NewTracerOptions(apm.TracerOptions{
158161
ServiceName: "fake-apm",
159162
ServiceVersion: "0.1",
@@ -204,7 +207,7 @@ func newFakeAPMInput(logger zerolog.Logger, logLevel client.UnitLogLevel, unit *
204207
logger = logger.Level(toZerologLevel(logLevel))
205208

206209
// close the default tracer to avoid unnecessary logs
207-
apm.DefaultTracer.Close()
210+
apm.DefaultTracer().Close()
208211

209212
apmInput := &fakeAPMInput{
210213
logger: logger,

pkg/component/runtime/manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"time"
2020

2121
"github.com/gofrs/uuid"
22-
"go.elastic.co/apm"
23-
"go.elastic.co/apm/module/apmgrpc"
22+
"go.elastic.co/apm/v2"
23+
"go.elastic.co/apm/module/apmgrpc/v2"
2424
"google.golang.org/grpc"
2525
"google.golang.org/grpc/codes"
2626
"google.golang.org/grpc/credentials"

pkg/component/runtime/manager_fake_input_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
"github.com/stretchr/testify/assert"
3232
"github.com/stretchr/testify/require"
3333
"github.com/stretchr/testify/suite"
34-
"go.elastic.co/apm/apmtest"
34+
"go.elastic.co/apm/v2/apmtest"
3535

3636
"github.com/elastic/elastic-agent-client/v7/pkg/client"
3737
"github.com/elastic/elastic-agent-client/v7/pkg/proto"

pkg/component/runtime/manager_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/stretchr/testify/require"
16-
"go.elastic.co/apm/apmtest"
16+
"go.elastic.co/apm/v2/apmtest"
1717

1818
"github.com/elastic/elastic-agent-client/v7/pkg/client"
1919
"github.com/elastic/elastic-agent-libs/logp"

pkg/control/v1/server/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/elastic/elastic-agent/pkg/control/v1/proto"
1212
v2proto "github.com/elastic/elastic-agent/pkg/control/v2/cproto"
1313

14-
"go.elastic.co/apm"
14+
"go.elastic.co/apm/v2"
1515

1616
"github.com/elastic/elastic-agent/internal/pkg/release"
1717
"github.com/elastic/elastic-agent/pkg/core/logger"

pkg/control/v2/control_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/elastic/elastic-agent/pkg/control/v2/client"
1212
"github.com/elastic/elastic-agent/pkg/control/v2/server"
1313

14-
"go.elastic.co/apm/apmtest"
14+
"go.elastic.co/apm/v2/apmtest"
1515

1616
"github.com/stretchr/testify/assert"
1717
"github.com/stretchr/testify/require"

0 commit comments

Comments
 (0)