From c419d391ae3699568af53dd4613378a8500001eb Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Tue, 24 May 2022 17:04:46 +0200 Subject: [PATCH] Add APM tracing for client-go requests to the Kubernetes API (#5651) This adds a custom APM round tripper for requests to the Kubernetes API. This can potentially be contributed to elastic/apm-agent-go as a new module. But I think it would be good to try it first in the context of the eck-operator. I structured the code in such a way to allow that if we decide it is worth contributing. Why a custom round tripper? To get a meaningful span summary that is specific to k8s. The current implementation is not perfect in this regard especially sub-resource requests are represented somewhat arbitrarily by subsections of the request path. The other thing implement here is to track requests done in the background by the client-go library to maintain the local cache. As far as I know there is no way to inject a context into the library that would enable tracing. This PR implements instead a default transaction mechanism to track those requests. --- NOTICE.txt | 499 ++++++++---------- cmd/manager/main.go | 18 +- docs/reference/dependencies.asciidoc | 15 +- go.mod | 15 +- go.sum | 39 +- pkg/controller/apmserver/controller.go | 2 +- pkg/controller/apmserver/deployment.go | 2 +- pkg/controller/association/reconciler.go | 2 +- pkg/controller/association/resources.go | 2 +- pkg/controller/association/service_account.go | 2 +- pkg/controller/association/user.go | 2 +- .../autoscaling/elasticsearch/driver.go | 2 +- .../autoscaling/elasticsearch/policy.go | 2 +- .../autoscaling/elasticsearch/reconcile.go | 2 +- pkg/controller/beat/controller.go | 2 +- .../common/certificates/reconcile.go | 2 +- pkg/controller/common/controller.go | 2 +- pkg/controller/common/http_client.go | 2 +- pkg/controller/common/operator/parameters.go | 2 +- pkg/controller/common/service_control.go | 2 +- .../common/tracing/apmclientgo/client.go | 182 +++++++ .../common/tracing/apmclientgo/client_test.go | 58 ++ pkg/controller/common/tracing/error.go | 2 +- pkg/controller/common/tracing/k8s.go | 33 ++ pkg/controller/common/tracing/log.go | 3 +- pkg/controller/common/tracing/spans.go | 2 +- pkg/controller/common/tracing/tracer.go | 2 +- pkg/controller/common/tracing/transaction.go | 2 +- .../elasticsearch/bootstrap/bootstrap.go | 2 +- .../elasticsearch/certificates/reconcile.go | 2 +- .../elasticsearch/cleanup/resources.go | 2 +- .../elasticsearch/configmap/configmap.go | 2 +- .../elasticsearch/driver/node_labels.go | 2 +- pkg/controller/elasticsearch/driver/nodes.go | 2 +- .../elasticsearch/elasticsearch_controller.go | 2 +- .../elasticsearch/observer/manager.go | 2 +- .../elasticsearch/observer/manager_test.go | 8 +- .../elasticsearch/observer/observer.go | 2 +- .../remotecluster/elasticsearch.go | 2 +- .../elasticsearch/settings/masters.go | 2 +- .../elasticsearch/user/reconcile.go | 2 +- pkg/controller/enterprisesearch/deployment.go | 2 +- .../enterprisesearch_controller.go | 2 +- pkg/controller/kibana/config_reconcile.go | 2 +- pkg/controller/kibana/config_settings.go | 2 +- pkg/controller/kibana/controller.go | 2 +- pkg/controller/kibana/driver.go | 2 +- pkg/controller/maps/controller.go | 2 +- pkg/controller/remoteca/controller.go | 2 +- pkg/controller/remoteca/secret.go | 2 +- pkg/controller/webhook/reconcile.go | 2 +- .../webhook_certificates_controller.go | 2 +- pkg/license/license.go | 2 +- pkg/license/reporter.go | 2 +- pkg/telemetry/telemetry.go | 2 +- pkg/utils/log/log.go | 2 +- 56 files changed, 607 insertions(+), 355 deletions(-) create mode 100644 pkg/controller/common/tracing/apmclientgo/client.go create mode 100644 pkg/controller/common/tracing/apmclientgo/client_test.go create mode 100644 pkg/controller/common/tracing/k8s.go diff --git a/NOTICE.txt b/NOTICE.txt index 68ece9de21..810c87a3b8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2567,12 +2567,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- -Module : go.elastic.co/apm -Version : v1.15.0 -Time : 2021-12-08T03:18:47Z +Module : go.elastic.co/apm/module/apmelasticsearch/v2 +Version : v2.0.0 +Time : 2022-03-17T05:06:42Z Licence : Apache-2.0 -Contents of probable licence file $GOMODCACHE/go.elastic.co/apm@v1.15.0/LICENSE: +Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/module/apmelasticsearch/v2@v2.0.0/LICENSE: Apache License Version 2.0, January 2004 @@ -2778,12 +2778,223 @@ Contents of probable licence file $GOMODCACHE/go.elastic.co/apm@v1.15.0/LICENSE: -------------------------------------------------------------------------------- -Module : go.elastic.co/apm/module/apmelasticsearch -Version : v1.15.0 -Time : 2021-12-08T03:18:47Z +Module : go.elastic.co/apm/module/apmhttp/v2 +Version : v2.0.0 +Time : 2022-03-17T05:06:42Z Licence : Apache-2.0 -Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/module/apmelasticsearch@v1.15.0/LICENSE: +Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/module/apmhttp/v2@v2.0.0/LICENSE: + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018 Elasticsearch BV + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------------------------------------------------------------------- +Module : go.elastic.co/apm/v2 +Version : v2.0.0 +Time : 2022-03-17T05:06:42Z +Licence : Apache-2.0 + +Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/v2@v2.0.0/LICENSE: Apache License Version 2.0, January 2004 @@ -6498,11 +6709,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- Module : github.com/elastic/go-licenser -Version : v0.3.1 -Time : 2019-10-14T11:24:07Z +Version : v0.4.0 +Time : 2021-11-03T09:41:34Z Licence : Apache-2.0 -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0.3.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0.4.0/LICENSE: Apache License @@ -6710,11 +6921,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0. -------------------------------------------------------------------------------- Module : github.com/elastic/go-sysinfo -Version : v1.1.1 -Time : 2019-10-29T16:55:22Z +Version : v1.7.1 +Time : 2021-10-11T20:19:28Z Licence : Apache-2.0 -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.1.1/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.7.1/LICENSE.txt: Apache License @@ -6922,11 +7133,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.1 -------------------------------------------------------------------------------- Module : github.com/elastic/go-windows -Version : v1.0.0 -Time : 2019-04-26T12:19:22Z +Version : v1.0.1 +Time : 2019-08-28T22:26:57Z Licence : Apache-2.0 -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-windows@v1.0.0/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-windows@v1.0.1/LICENSE.txt: Apache License @@ -19219,217 +19430,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Module : go.elastic.co/apm/module/apmhttp -Version : v1.15.0 -Time : 2021-12-08T03:18:47Z -Licence : Apache-2.0 - -Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/module/apmhttp@v1.15.0/LICENSE: - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2018 Elasticsearch BV - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - -------------------------------------------------------------------------------- Module : go.elastic.co/fastjson Version : v1.1.0 @@ -19589,43 +19589,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Module : golang.org/x/lint -Version : v0.0.0-20210508222113-6edffad5e616 -Time : 2021-05-08T22:21:13Z -Licence : BSD-3-Clause - -Contents of probable licence file $GOMODCACHE/golang.org/x/lint@v0.0.0-20210508222113-6edffad5e616/LICENSE: - -Copyright (c) 2013 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -------------------------------------------------------------------------------- Module : golang.org/x/mod Version : v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 @@ -21426,11 +21389,11 @@ limitations under the License. -------------------------------------------------------------------------------- Module : howett.net/plist -Version : v0.0.0-20181124034731-591f970eefbb -Time : 2018-11-24T03:47:31Z +Version : v1.0.0 +Time : 2021-11-27T22:07:39Z Licence : BSD-2-Clause -Contents of probable licence file $GOMODCACHE/howett.net/plist@v0.0.0-20181124034731-591f970eefbb/LICENSE: +Contents of probable licence file $GOMODCACHE/howett.net/plist@v1.0.0/LICENSE: Copyright (c) 2013, Dustin L. Howett. All rights reserved. diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 7bafe54166..5e34ce302c 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -19,7 +19,7 @@ import ( "github.com/go-logr/logr" "github.com/spf13/cobra" "github.com/spf13/viper" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "go.uber.org/automaxprocs/maxprocs" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -65,6 +65,7 @@ import ( "github.com/elastic/cloud-on-k8s/pkg/controller/common/reconciler" controllerscheme "github.com/elastic/cloud-on-k8s/pkg/controller/common/scheme" "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing" + "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing/apmclientgo" "github.com/elastic/cloud-on-k8s/pkg/controller/common/version" commonwebhook "github.com/elastic/cloud-on-k8s/pkg/controller/common/webhook" "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch" @@ -457,9 +458,18 @@ func startOperator(ctx context.Context) error { return err } + // set up APM tracing if configured + var tracer *apm.Tracer + if viper.GetBool(operator.EnableTracingFlag) { + tracer = tracing.NewTracer("elastic-operator") + // set up APM tracing for client-go + cfg.Wrap(tracing.ClientGoTransportWrapper( + apmclientgo.WithDefaultTransaction(tracing.ClientGoCacheTx(tracer)), + )) + } + // set the timeout for API client cfg.Timeout = viper.GetDuration(operator.KubeClientTimeout) - // set the timeout for Elasticsearch requests esclient.DefaultESClientTimeout = viper.GetDuration(operator.ElasticsearchClientTimeout) @@ -556,10 +566,6 @@ func startOperator(ctx context.Context) error { } log.Info("Setting up controllers") - var tracer *apm.Tracer - if viper.GetBool(operator.EnableTracingFlag) { - tracer = tracing.NewTracer("elastic-operator") - } exposedNodeLabels, err := esvalidation.NewExposedNodeLabels(viper.GetStringSlice(operator.ExposedNodeLabels)) if err != nil { diff --git a/docs/reference/dependencies.asciidoc b/docs/reference/dependencies.asciidoc index 4b0bb34336..1c882a8361 100644 --- a/docs/reference/dependencies.asciidoc +++ b/docs/reference/dependencies.asciidoc @@ -44,8 +44,9 @@ This page lists the third-party dependencies used to build {n}. | link:https://github.com/spf13/viper[$$github.com/spf13/viper$$] | v1.11.0 | MIT | link:https://github.com/stretchr/testify[$$github.com/stretchr/testify$$] | v1.7.1 | MIT | link:https://github.com/tsenart/vegeta[$$github.com/tsenart/vegeta$$] | v12.7.0+incompatible | MIT -| link:https://go.elastic.co/apm[$$go.elastic.co/apm$$] | v1.15.0 | Apache-2.0 -| link:https://go.elastic.co/apm/module/apmelasticsearch[$$go.elastic.co/apm/module/apmelasticsearch$$] | v1.15.0 | Apache-2.0 +| link:https://go.elastic.co/apm/module/apmelasticsearch/v2[$$go.elastic.co/apm/module/apmelasticsearch/v2$$] | v2.0.0 | Apache-2.0 +| link:https://go.elastic.co/apm/module/apmhttp/v2[$$go.elastic.co/apm/module/apmhttp/v2$$] | v2.0.0 | Apache-2.0 +| link:https://go.elastic.co/apm/v2[$$go.elastic.co/apm/v2$$] | v2.0.0 | Apache-2.0 | link:https://go.uber.org/automaxprocs[$$go.uber.org/automaxprocs$$] | v1.5.1 | MIT | link:https://go.uber.org/zap[$$go.uber.org/zap$$] | v1.21.0 | MIT | link:https://golang.org/x/crypto[$$golang.org/x/crypto$$] | v0.0.0-20220411220226-7b82a4e95df4 | BSD-3-Clause @@ -89,9 +90,9 @@ This page lists the third-party dependencies used to build {n}. | link:https://github.com/docker/distribution[$$github.com/docker/distribution$$] | v2.8.1+incompatible | Apache-2.0 | link:https://github.com/docker/docker[$$github.com/docker/docker$$] | v20.10.16+incompatible | Apache-2.0 | link:https://github.com/docker/docker-credential-helpers[$$github.com/docker/docker-credential-helpers$$] | v0.6.4 | MIT -| link:https://github.com/elastic/go-licenser[$$github.com/elastic/go-licenser$$] | v0.3.1 | Apache-2.0 -| link:https://github.com/elastic/go-sysinfo[$$github.com/elastic/go-sysinfo$$] | v1.1.1 | Apache-2.0 -| link:https://github.com/elastic/go-windows[$$github.com/elastic/go-windows$$] | v1.0.0 | Apache-2.0 +| link:https://github.com/elastic/go-licenser[$$github.com/elastic/go-licenser$$] | v0.4.0 | Apache-2.0 +| link:https://github.com/elastic/go-sysinfo[$$github.com/elastic/go-sysinfo$$] | v1.7.1 | Apache-2.0 +| link:https://github.com/elastic/go-windows[$$github.com/elastic/go-windows$$] | v1.0.1 | Apache-2.0 | link:https://github.com/elazarl/goproxy[$$github.com/elazarl/goproxy$$] | v0.0.0-20190711103511-473e67f1d7d2 | BSD-3-Clause | link:https://github.com/emicklei/go-restful[$$github.com/emicklei/go-restful$$] | v2.9.5+incompatible | MIT | link:https://github.com/evanphx/json-patch[$$github.com/evanphx/json-patch$$] | v4.12.0+incompatible | BSD-3-Clause @@ -174,13 +175,11 @@ This page lists the third-party dependencies used to build {n}. | link:https://github.com/stretchr/objx[$$github.com/stretchr/objx$$] | v0.1.1 | MIT | link:https://github.com/subosito/gotenv[$$github.com/subosito/gotenv$$] | v1.2.0 | MIT | link:https://github.com/vbatts/tar-split[$$github.com/vbatts/tar-split$$] | v0.11.2 | BSD-3-Clause -| link:https://go.elastic.co/apm/module/apmhttp[$$go.elastic.co/apm/module/apmhttp$$] | v1.15.0 | Apache-2.0 | link:https://go.elastic.co/fastjson[$$go.elastic.co/fastjson$$] | v1.1.0 | MIT | link:https://go.uber.org/atomic[$$go.uber.org/atomic$$] | v1.9.0 | MIT | link:https://go.uber.org/goleak[$$go.uber.org/goleak$$] | v1.1.12 | MIT | link:https://go.uber.org/multierr[$$go.uber.org/multierr$$] | v1.6.0 | MIT | link:https://golang.org/x/exp[$$golang.org/x/exp$$] | v0.0.0-20200224162631-6cc2880d07d6 | BSD-3-Clause -| link:https://golang.org/x/lint[$$golang.org/x/lint$$] | v0.0.0-20210508222113-6edffad5e616 | BSD-3-Clause | link:https://golang.org/x/mod[$$golang.org/x/mod$$] | v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 | BSD-3-Clause | link:https://golang.org/x/net[$$golang.org/x/net$$] | v0.0.0-20220516155154-20f960328961 | BSD-3-Clause | link:https://golang.org/x/oauth2[$$golang.org/x/oauth2$$] | v0.0.0-20220411215720-9780585627b5 | BSD-3-Clause @@ -202,7 +201,7 @@ This page lists the third-party dependencies used to build {n}. | link:https://gopkg.in/square/go-jose.v2[$$gopkg.in/square/go-jose.v2$$] | v2.5.1 | Apache-2.0 | link:https://gopkg.in/tomb.v1[$$gopkg.in/tomb.v1$$] | v1.0.0-20141024135613-dd632973f1e7 | BSD-3-Clause | link:https://gotest.tools/v3[$$gotest.tools/v3$$] | v3.0.3 | Apache-2.0 -| link:https://gitlab.howett.net/go/plist[$$howett.net/plist$$] | v0.0.0-20181124034731-591f970eefbb | BSD-2-Clause +| link:https://gitlab.howett.net/go/plist[$$howett.net/plist$$] | v1.0.0 | BSD-2-Clause | link:https://github.com/kubernetes/apiextensions-apiserver[$$k8s.io/apiextensions-apiserver$$] | v0.24.0 | Apache-2.0 | link:https://github.com/kubernetes/component-base[$$k8s.io/component-base$$] | v0.24.0 | Apache-2.0 | link:https://github.com/kubernetes/kube-openapi[$$k8s.io/kube-openapi$$] | v0.0.0-20220328201542-3ee0da9b0b42 | Apache-2.0 diff --git a/go.mod b/go.mod index 2bb259383a..9d336bf226 100644 --- a/go.mod +++ b/go.mod @@ -31,8 +31,9 @@ require ( github.com/spf13/viper v1.11.0 github.com/stretchr/testify v1.7.1 github.com/tsenart/vegeta v12.7.0+incompatible - go.elastic.co/apm v1.15.0 - go.elastic.co/apm/module/apmelasticsearch v1.15.0 + go.elastic.co/apm/module/apmelasticsearch/v2 v2.0.0 + go.elastic.co/apm/module/apmhttp/v2 v2.0.0 + go.elastic.co/apm/v2 v2.0.0 go.uber.org/automaxprocs v1.5.1 go.uber.org/zap v1.21.0 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 @@ -66,9 +67,9 @@ require ( github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker v20.10.16+incompatible // indirect github.com/docker/docker-credential-helpers v0.6.4 // indirect - github.com/elastic/go-licenser v0.3.1 // indirect - github.com/elastic/go-sysinfo v1.1.1 // indirect - github.com/elastic/go-windows v1.0.0 // indirect + github.com/elastic/go-licenser v0.4.0 // indirect + github.com/elastic/go-sysinfo v1.7.1 // indirect + github.com/elastic/go-windows v1.0.1 // indirect github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2 // indirect github.com/emicklei/go-restful v2.9.5+incompatible // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect @@ -140,11 +141,9 @@ require ( github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect github.com/subosito/gotenv v1.2.0 // indirect github.com/vbatts/tar-split v0.11.2 // indirect - go.elastic.co/apm/module/apmhttp v1.15.0 // indirect go.elastic.co/fastjson v1.1.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/net v0.0.0-20220516155154-20f960328961 // indirect golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect @@ -162,7 +161,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/square/go-jose.v2 v2.5.1 // indirect - howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect + howett.net/plist v1.0.0 // indirect k8s.io/apiextensions-apiserver v0.24.0 // indirect k8s.io/component-base v0.24.0 // indirect k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect diff --git a/go.sum b/go.sum index 94f52450dc..ebcb35096c 100644 --- a/go.sum +++ b/go.sum @@ -168,14 +168,15 @@ github.com/docker/docker-credential-helpers v0.6.4 h1:axCks+yV+2MR3/kZhAmy07yC56 github.com/docker/docker-credential-helpers v0.6.4/go.mod h1:ofX3UI0Gz1TteYBjtgs07O36Pyasyp66D2uKT7H8W1c= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/elastic/go-licenser v0.3.1 h1:RmRukU/JUmts+rpexAw0Fvt2ly7VVu6mw8z4HrEzObU= -github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ= -github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI= -github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= +github.com/elastic/go-licenser v0.4.0 h1:jLq6A5SilDS/Iz1ABRkO6BHy91B9jBora8FwGRsDqUI= +github.com/elastic/go-licenser v0.4.0/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU= +github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO+s0= +github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-ucfg v0.8.5 h1:4GB/rMpuh7qTcSFaxJUk97a/JyvFzhi6t+kaskTTLdM= github.com/elastic/go-ucfg v0.8.5/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA= -github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= +github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0= +github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2 h1:aZtFdDNWY/yH86JPR2WX/PN63635VsE/f/nXNPAbYxY= github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= @@ -691,13 +692,15 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.elastic.co/apm v1.15.0 h1:uPk2g/whK7c7XiZyz/YCUnAUBNPiyNeE3ARX3G6Gx7Q= -go.elastic.co/apm v1.15.0/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY= -go.elastic.co/apm/module/apmelasticsearch v1.15.0 h1:c5/qg+9AYe1QCGhu7FGqoydY9NNkNzc+iRpJJXRK/WE= -go.elastic.co/apm/module/apmelasticsearch v1.15.0/go.mod h1:TO6L5GJoJNavqJfksrUnnEG485VNQvZRpsmrwJW9LN8= -go.elastic.co/apm/module/apmhttp v1.15.0 h1:Le/DhI0Cqpr9wG/NIGOkbz7+rOMqJrfE4MRG6q/+leU= -go.elastic.co/apm/module/apmhttp v1.15.0/go.mod h1:NruY6Jq8ALLzWUVUQ7t4wIzn+onKoiP5woJJdTV7GMg= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.elastic.co/apm/module/apmelasticsearch/v2 v2.0.0 h1:5UaI4agfuGoGRhpFVb6s63Hj/9xtqYxF7kd6T77tNAw= +go.elastic.co/apm/module/apmelasticsearch/v2 v2.0.0/go.mod h1:GmYz+KDp2LDAa2nd/qJ+OkrjWVEoCRIPAWarbUvyt6Y= +go.elastic.co/apm/module/apmhttp/v2 v2.0.0 h1:GNfmK1LD4nE5fYqbLxROCpg1ucyjSFG5iwulxwAJ+3o= +go.elastic.co/apm/module/apmhttp/v2 v2.0.0/go.mod h1:5KmxcNN7hkJh8sVW3Ggl/pYgnwiNenygE46bZoUb9RE= +go.elastic.co/apm/v2 v2.0.0 h1:5BeBh+oIrVbMwPrW3uO9Uxm4w7HpKy92lYl5Rfj69Kg= +go.elastic.co/apm/v2 v2.0.0/go.mod h1:KGQn56LtRmkQjt2qw4+c1Jz8gv9rCBUU/m21uxrqcps= go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -790,7 +793,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -803,6 +805,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -852,8 +855,10 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -911,6 +916,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -963,11 +969,14 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211102192858-4dd72447c267/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1062,6 +1071,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10-0.20220218145154-897bd77cd717/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= @@ -1254,6 +1265,7 @@ gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1279,8 +1291,9 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= +howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= +howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= k8s.io/api v0.24.0 h1:J0hann2hfxWr1hinZIDefw7Q96wmCBx6SSB8IY0MdDg= k8s.io/api v0.24.0/go.mod h1:5Jl90IUrJHUJYEMANRURMiVvJ0g7Ax7r3R1bqO8zx8I= k8s.io/apiextensions-apiserver v0.24.0 h1:JfgFqbA8gKJ/uDT++feAqk9jBIwNnL9YGdQvaI9DLtY= diff --git a/pkg/controller/apmserver/controller.go b/pkg/controller/apmserver/controller.go index e74f631f24..c6ad57ddbd 100644 --- a/pkg/controller/apmserver/controller.go +++ b/pkg/controller/apmserver/controller.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "github.com/blang/semver/v4" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/apmserver/deployment.go b/pkg/controller/apmserver/deployment.go index a195029b18..a0420d0054 100644 --- a/pkg/controller/apmserver/deployment.go +++ b/pkg/controller/apmserver/deployment.go @@ -9,7 +9,7 @@ import ( "fmt" "hash/fnv" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/association/reconciler.go b/pkg/controller/association/reconciler.go index aaa2e76b7f..0a9395b0f4 100644 --- a/pkg/controller/association/reconciler.go +++ b/pkg/controller/association/reconciler.go @@ -12,7 +12,7 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/controller/association/resources.go b/pkg/controller/association/resources.go index d3e7683e7c..b47766dc18 100644 --- a/pkg/controller/association/resources.go +++ b/pkg/controller/association/resources.go @@ -7,7 +7,7 @@ package association import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/association/service_account.go b/pkg/controller/association/service_account.go index 135f67a4b6..864fbdc095 100644 --- a/pkg/controller/association/service_account.go +++ b/pkg/controller/association/service_account.go @@ -15,7 +15,7 @@ import ( "strconv" "strings" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "golang.org/x/crypto/pbkdf2" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/association/user.go b/pkg/controller/association/user.go index 45ae27f959..c054ff5dac 100644 --- a/pkg/controller/association/user.go +++ b/pkg/controller/association/user.go @@ -7,7 +7,7 @@ package association import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "golang.org/x/crypto/bcrypt" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/autoscaling/elasticsearch/driver.go b/pkg/controller/autoscaling/elasticsearch/driver.go index 6a4bd3c1da..50e29ddc06 100644 --- a/pkg/controller/autoscaling/elasticsearch/driver.go +++ b/pkg/controller/autoscaling/elasticsearch/driver.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/go-logr/logr" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" apierrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/reconcile" diff --git a/pkg/controller/autoscaling/elasticsearch/policy.go b/pkg/controller/autoscaling/elasticsearch/policy.go index a3e8635eae..45f75480eb 100644 --- a/pkg/controller/autoscaling/elasticsearch/policy.go +++ b/pkg/controller/autoscaling/elasticsearch/policy.go @@ -8,7 +8,7 @@ import ( "context" "github.com/go-logr/logr" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing" diff --git a/pkg/controller/autoscaling/elasticsearch/reconcile.go b/pkg/controller/autoscaling/elasticsearch/reconcile.go index 0ce9795a9e..f1f07dfb47 100644 --- a/pkg/controller/autoscaling/elasticsearch/reconcile.go +++ b/pkg/controller/autoscaling/elasticsearch/reconcile.go @@ -9,7 +9,7 @@ import ( "fmt" "github.com/go-logr/logr" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/beat/controller.go b/pkg/controller/beat/controller.go index b9186800c2..cf5a44b066 100644 --- a/pkg/controller/beat/controller.go +++ b/pkg/controller/beat/controller.go @@ -7,7 +7,7 @@ package beat import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/common/certificates/reconcile.go b/pkg/controller/common/certificates/reconcile.go index 7d355ee2cb..8d28a46610 100644 --- a/pkg/controller/common/certificates/reconcile.go +++ b/pkg/controller/common/certificates/reconcile.go @@ -8,7 +8,7 @@ import ( "context" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controller/common/controller.go b/pkg/controller/common/controller.go index 33d6d4fa1a..9a980aef5f 100644 --- a/pkg/controller/common/controller.go +++ b/pkg/controller/common/controller.go @@ -9,7 +9,7 @@ import ( "strconv" "sync/atomic" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" diff --git a/pkg/controller/common/http_client.go b/pkg/controller/common/http_client.go index 19c25fe253..14cf679f6b 100644 --- a/pkg/controller/common/http_client.go +++ b/pkg/controller/common/http_client.go @@ -11,7 +11,7 @@ import ( "net/http" "time" - "go.elastic.co/apm/module/apmelasticsearch" + "go.elastic.co/apm/module/apmelasticsearch/v2" "github.com/elastic/cloud-on-k8s/pkg/utils/cryptutil" "github.com/elastic/cloud-on-k8s/pkg/utils/net" diff --git a/pkg/controller/common/operator/parameters.go b/pkg/controller/common/operator/parameters.go index 0394a6458b..d2a5eb379e 100644 --- a/pkg/controller/common/operator/parameters.go +++ b/pkg/controller/common/operator/parameters.go @@ -5,7 +5,7 @@ package operator import ( - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "github.com/elastic/cloud-on-k8s/pkg/about" diff --git a/pkg/controller/common/service_control.go b/pkg/controller/common/service_control.go index f5d05b15ac..98b4582389 100644 --- a/pkg/controller/common/service_control.go +++ b/pkg/controller/common/service_control.go @@ -9,7 +9,7 @@ import ( "net" "reflect" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controller/common/tracing/apmclientgo/client.go b/pkg/controller/common/tracing/apmclientgo/client.go new file mode 100644 index 0000000000..3384c1cda9 --- /dev/null +++ b/pkg/controller/common/tracing/apmclientgo/client.go @@ -0,0 +1,182 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package apmclientgo + +import ( + "io" + "net/http" + "strings" + "sync/atomic" + "unsafe" + + "github.com/pkg/errors" + "go.elastic.co/apm/module/apmhttp/v2" + "go.elastic.co/apm/v2" +) + +// WrapRoundTripper returns a http.Roundtripper wrapping r, reporting each +// request as a span to Elastic APM, if the request's context contains a sampled transaction +// Allows an optional default transaction to be configured for requests where context cannot be controlled +// for example client-go's cache management +func WrapRoundTripper(r http.RoundTripper, o ...ClientOption) http.RoundTripper { + if r == nil { + r = http.DefaultTransport + } + rt := &roundTripper{r: r} + // apply any client options + for _, o := range o { + o(rt) + } + return rt +} + +type roundTripper struct { + r http.RoundTripper + defaultTxFn func() *apm.Transaction +} + +func (r roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + ctx := req.Context() + tx := apm.TransactionFromContext(ctx) + if tx == nil && r.defaultTxFn != nil { + tx = r.defaultTxFn() + if tx != nil { + defer tx.End() + } + } + if tx == nil { + return r.r.RoundTrip(req) + } + traceContext := tx.TraceContext() + if !tx.Sampled() { + apmhttp.SetHeaders(req, traceContext, false) + return r.r.RoundTrip(req) + } + + propagateLegacyHeader := tx.ShouldPropagateLegacyHeader() + requestName := requestName(req) + name := spanName(requestName) + span := tx.StartSpan(name, "db.kubernetes", apm.SpanFromContext(ctx)) + + if span.Dropped() { + span.End() + apmhttp.SetHeaders(req, traceContext, propagateLegacyHeader) + return r.r.RoundTrip(req) + } + + traceContext = span.TraceContext() + ctx = apm.ContextWithSpan(ctx, span) + req = apmhttp.RequestWithContext(ctx, req) + span.Context.SetHTTPRequest(req) + span.Context.SetDestinationService(apm.DestinationServiceSpanContext{ + Name: "Kubernetes API server", + Resource: "Kubernetes", + }) + span.Context.SetDatabase(apm.DatabaseSpanContext{ + Statement: requestName, + Type: "kubernetes", + }) + + apmhttp.SetHeaders(req, traceContext, propagateLegacyHeader) + resp, err := r.r.RoundTrip(req) + if err != nil { + span.End() + } else { + span.Context.SetHTTPStatusCode(resp.StatusCode) + resp.Body = &responseBody{span: span, body: resp.Body} + } + return resp, err +} + +// CloseIdleConnections calls r.r.CloseIdleConnections if the method exists. +func (r *roundTripper) CloseIdleConnections() { + type closeIdler interface { + CloseIdleConnections() + } + if tr, ok := r.r.(closeIdler); ok { + tr.CloseIdleConnections() + } +} + +// CancelRequest calls r.r.CancelRequest(req) if the method exists. +func (r *roundTripper) CancelRequest(req *http.Request) { + type cancelRequester interface { + CancelRequest(*http.Request) + } + if r, ok := r.r.(cancelRequester); ok { + r.CancelRequest(req) + } +} + +type responseBody struct { + span *apm.Span + body io.ReadCloser +} + +// Close closes the response body, and ends the span if it hasn't already been ended. +func (b *responseBody) Close() error { + b.endSpan() + return b.body.Close() +} + +// Read reads from the response body, and ends the span when io.EOF is returned if +// the span hasn't already been ended. +func (b *responseBody) Read(p []byte) (n int, err error) { + n, err = b.body.Read(p) + if errors.Is(err, io.EOF) { + b.endSpan() + } + return n, err +} + +func (b *responseBody) endSpan() { + addr := (*unsafe.Pointer)(unsafe.Pointer(&b.span)) + if old := atomic.SwapPointer(addr, nil); old != nil { + (*apm.Span)(old).End() + } +} + +func spanName(reqName string) string { + const prefix = "Kubernetes:" + var b strings.Builder + b.Grow(len(prefix) + 1 + len(reqName)) + b.WriteString(prefix) + b.WriteRune(' ') + b.WriteString(reqName) + return b.String() +} + +func requestName(req *http.Request) string { + statement := req.Method + numSegments := 2 + // add a bit more context in the summary for PUT requests e.g. namespace + if req.Method == "PUT" { + numSegments = 3 + } + + pathSegments := strings.Split(req.URL.Path, "/") + path := strings.Join(pathSegments[len(pathSegments)-numSegments:], "/") + // let's call out watch requests explicitly + if watch := req.URL.Query().Get("watch"); watch == "true" { + statement = "WATCH" + } + var b strings.Builder + b.Grow(len(statement) + 1 + len(path)) + b.WriteString(statement) + b.WriteRune(' ') + b.WriteString(path) + return b.String() +} + +// ClientOption sets options for tracing client requests. +type ClientOption func(*roundTripper) + +// WithDefaultTransaction configures the roundtripper to start a new APM transaction if no transaction is currently running +// using the factory function f. +func WithDefaultTransaction(f func() *apm.Transaction) ClientOption { + return ClientOption(func(rt *roundTripper) { + rt.defaultTxFn = f + }) +} diff --git a/pkg/controller/common/tracing/apmclientgo/client_test.go b/pkg/controller/common/tracing/apmclientgo/client_test.go new file mode 100644 index 0000000000..40f2871337 --- /dev/null +++ b/pkg/controller/common/tracing/apmclientgo/client_test.go @@ -0,0 +1,58 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package apmclientgo + +import ( + "net/http" + "testing" +) + +func Test_requestName(t *testing.T) { + type args struct { + req *http.Request + } + tests := []struct { + name string + args args + want string + }{ + { + name: "WATCH request", + args: args{ + req: mustRequest("GET", "https://34.76.65.60/apis/elasticsearch.k8s.elastic.co/v1/elasticsearches?allowWatchBookmarks=true&resourceVersion=11980723&timeout=1m0s&timeoutSeconds=526&watch=true"), + }, + want: "WATCH v1/elasticsearches", + }, + { + name: "PUT request", + args: args{ + req: mustRequest("PUT", "https://34.76.65.60/api/v1/namespaces/default/services/elasticsearch-es-transport?timeout=1m0s"), + }, + want: "PUT default/services/elasticsearch-es-transport", // no version on single resources requests, but maybe namespace? + }, + { + name: "list request", + args: args{ + req: mustRequest("GET", "https://34.76.65.60/apis/policy/v1beta1/poddisruptionbudgets?limit=500&resourceVersion=0&timeout=1m0s"), + }, + want: "GET v1beta1/poddisruptionbudgets", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := requestName(tt.args.req); got != tt.want { + t.Errorf("requestName() = %v, want %v", got, tt.want) + } + }) + } +} + +func mustRequest(method, url string) *http.Request { + request, err := http.NewRequest(method, url, nil) //nolint:noctx + if err != nil { + panic(err) + } + return request +} diff --git a/pkg/controller/common/tracing/error.go b/pkg/controller/common/tracing/error.go index a78595311a..313c461845 100644 --- a/pkg/controller/common/tracing/error.go +++ b/pkg/controller/common/tracing/error.go @@ -7,7 +7,7 @@ package tracing import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" ) // CaptureError wraps APM agent func of the same name and auto-sends, returning the original error. diff --git a/pkg/controller/common/tracing/k8s.go b/pkg/controller/common/tracing/k8s.go new file mode 100644 index 0000000000..b9067405c2 --- /dev/null +++ b/pkg/controller/common/tracing/k8s.go @@ -0,0 +1,33 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package tracing + +import ( + "net/http" + + "go.elastic.co/apm/v2" + "k8s.io/client-go/transport" + + "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing/apmclientgo" +) + +func ClientGoTransportWrapper(o ...apmclientgo.ClientOption) transport.WrapperFunc { + return func(rt http.RoundTripper) http.RoundTripper { + return apmclientgo.WrapRoundTripper(rt, o...) + } +} + +// ClientGoCacheTx creates a new apm.Transaction for cache refresh requests. If no APM transaction is running +// we assume the transaction is used to manage the client-go cache, as we cannot inject a context into those +// requests. All other requests should have a properly initialised transaction originating in the operator code. +func ClientGoCacheTx(tracer *apm.Tracer) func() *apm.Transaction { + return func() *apm.Transaction { + if tracer == nil { + return nil + } + // if no transaction is running assume we are tracing cache refresh requests from client-go + return tracer.StartTransaction("cache", "client-go") + } +} diff --git a/pkg/controller/common/tracing/log.go b/pkg/controller/common/tracing/log.go index a9d52e5284..f1b7b40d97 100644 --- a/pkg/controller/common/tracing/log.go +++ b/pkg/controller/common/tracing/log.go @@ -9,7 +9,7 @@ import ( "github.com/go-logr/logr" pkgerrors "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" ) // NewLogAdapter returns an implementation of the log interface expected by the APM agent. @@ -36,4 +36,3 @@ func (l *logAdapter) Debugf(format string, args ...interface{}) { } var _ apm.Logger = &logAdapter{} -var _ apm.WarningLogger = &logAdapter{} diff --git a/pkg/controller/common/tracing/spans.go b/pkg/controller/common/tracing/spans.go index e134f929e8..b380807e4a 100644 --- a/pkg/controller/common/tracing/spans.go +++ b/pkg/controller/common/tracing/spans.go @@ -9,7 +9,7 @@ import ( "runtime" "strings" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" ) const ( diff --git a/pkg/controller/common/tracing/tracer.go b/pkg/controller/common/tracing/tracer.go index ae54d8ee66..beada46bd1 100644 --- a/pkg/controller/common/tracing/tracer.go +++ b/pkg/controller/common/tracing/tracer.go @@ -5,7 +5,7 @@ package tracing import ( - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "github.com/elastic/cloud-on-k8s/pkg/about" ulog "github.com/elastic/cloud-on-k8s/pkg/utils/log" diff --git a/pkg/controller/common/tracing/transaction.go b/pkg/controller/common/tracing/transaction.go index f67ed97fbd..45a6cf60c2 100644 --- a/pkg/controller/common/tracing/transaction.go +++ b/pkg/controller/common/tracing/transaction.go @@ -7,7 +7,7 @@ package tracing import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "k8s.io/apimachinery/pkg/types" ) diff --git a/pkg/controller/elasticsearch/bootstrap/bootstrap.go b/pkg/controller/elasticsearch/bootstrap/bootstrap.go index cd778d2ff2..dcc437fc6e 100644 --- a/pkg/controller/elasticsearch/bootstrap/bootstrap.go +++ b/pkg/controller/elasticsearch/bootstrap/bootstrap.go @@ -7,7 +7,7 @@ package bootstrap import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1" "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing" diff --git a/pkg/controller/elasticsearch/certificates/reconcile.go b/pkg/controller/elasticsearch/certificates/reconcile.go index f86d9869f7..0abce3ce3b 100644 --- a/pkg/controller/elasticsearch/certificates/reconcile.go +++ b/pkg/controller/elasticsearch/certificates/reconcile.go @@ -9,7 +9,7 @@ import ( "crypto/x509" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" commonv1 "github.com/elastic/cloud-on-k8s/pkg/apis/common/v1" diff --git a/pkg/controller/elasticsearch/cleanup/resources.go b/pkg/controller/elasticsearch/cleanup/resources.go index 6d3656de4a..b2c706b1c1 100644 --- a/pkg/controller/elasticsearch/cleanup/resources.go +++ b/pkg/controller/elasticsearch/cleanup/resources.go @@ -8,7 +8,7 @@ import ( "context" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" diff --git a/pkg/controller/elasticsearch/configmap/configmap.go b/pkg/controller/elasticsearch/configmap/configmap.go index 7d4c767e67..f9ed174f3a 100644 --- a/pkg/controller/elasticsearch/configmap/configmap.go +++ b/pkg/controller/elasticsearch/configmap/configmap.go @@ -7,7 +7,7 @@ package configmap import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/elasticsearch/driver/node_labels.go b/pkg/controller/elasticsearch/driver/node_labels.go index 363a526888..581a2087fe 100644 --- a/pkg/controller/elasticsearch/driver/node_labels.go +++ b/pkg/controller/elasticsearch/driver/node_labels.go @@ -10,7 +10,7 @@ import ( "fmt" "strings" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/elasticsearch/driver/nodes.go b/pkg/controller/elasticsearch/driver/nodes.go index 9247ee81a4..df2b78e40e 100644 --- a/pkg/controller/elasticsearch/driver/nodes.go +++ b/pkg/controller/elasticsearch/driver/nodes.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1" diff --git a/pkg/controller/elasticsearch/elasticsearch_controller.go b/pkg/controller/elasticsearch/elasticsearch_controller.go index 6e9a9494cf..24584e2e2e 100644 --- a/pkg/controller/elasticsearch/elasticsearch_controller.go +++ b/pkg/controller/elasticsearch/elasticsearch_controller.go @@ -10,7 +10,7 @@ import ( "sync/atomic" pkgerrors "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/elasticsearch/observer/manager.go b/pkg/controller/elasticsearch/observer/manager.go index 113ca48c14..b736cabb44 100644 --- a/pkg/controller/elasticsearch/observer/manager.go +++ b/pkg/controller/elasticsearch/observer/manager.go @@ -7,7 +7,7 @@ package observer import ( "sync" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "k8s.io/apimachinery/pkg/types" esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1" diff --git a/pkg/controller/elasticsearch/observer/manager_test.go b/pkg/controller/elasticsearch/observer/manager_test.go index 6baa7c8408..ae9d331cdb 100644 --- a/pkg/controller/elasticsearch/observer/manager_test.go +++ b/pkg/controller/elasticsearch/observer/manager_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/stretchr/testify/require" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -262,8 +262,8 @@ func TestSettingsComparison(t *testing.T) { }, { name: "same settings (non nil tracer)", - s1: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer}, - s2: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer}, + s1: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer()}, + s2: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer()}, want: true, }, { @@ -274,7 +274,7 @@ func TestSettingsComparison(t *testing.T) { }, { name: "different tracers", - s1: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer}, + s1: Settings{ObservationInterval: 1 * time.Second, Tracer: apm.DefaultTracer()}, s2: Settings{ObservationInterval: 1 * time.Second}, want: false, }, diff --git a/pkg/controller/elasticsearch/observer/observer.go b/pkg/controller/elasticsearch/observer/observer.go index e9202a0924..1fb8bc8aa9 100644 --- a/pkg/controller/elasticsearch/observer/observer.go +++ b/pkg/controller/elasticsearch/observer/observer.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "k8s.io/apimachinery/pkg/types" esv1 "github.com/elastic/cloud-on-k8s/pkg/apis/elasticsearch/v1" diff --git a/pkg/controller/elasticsearch/remotecluster/elasticsearch.go b/pkg/controller/elasticsearch/remotecluster/elasticsearch.go index 113b96fe75..c96504c5b5 100644 --- a/pkg/controller/elasticsearch/remotecluster/elasticsearch.go +++ b/pkg/controller/elasticsearch/remotecluster/elasticsearch.go @@ -8,7 +8,7 @@ import ( "context" "sort" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/record" diff --git a/pkg/controller/elasticsearch/settings/masters.go b/pkg/controller/elasticsearch/settings/masters.go index ff2d55b5ee..bf9cec9a4c 100644 --- a/pkg/controller/elasticsearch/settings/masters.go +++ b/pkg/controller/elasticsearch/settings/masters.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/controller/elasticsearch/user/reconcile.go b/pkg/controller/elasticsearch/user/reconcile.go index 946dfa8caa..239e69bc96 100644 --- a/pkg/controller/elasticsearch/user/reconcile.go +++ b/pkg/controller/elasticsearch/user/reconcile.go @@ -8,7 +8,7 @@ import ( "context" "reflect" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/enterprisesearch/deployment.go b/pkg/controller/enterprisesearch/deployment.go index d1b11b4a20..c5315cee8a 100644 --- a/pkg/controller/enterprisesearch/deployment.go +++ b/pkg/controller/enterprisesearch/deployment.go @@ -7,7 +7,7 @@ package enterprisesearch import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" entv1 "github.com/elastic/cloud-on-k8s/pkg/apis/enterprisesearch/v1" diff --git a/pkg/controller/enterprisesearch/enterprisesearch_controller.go b/pkg/controller/enterprisesearch/enterprisesearch_controller.go index 2efa5aa62e..d3c54590fe 100644 --- a/pkg/controller/enterprisesearch/enterprisesearch_controller.go +++ b/pkg/controller/enterprisesearch/enterprisesearch_controller.go @@ -11,7 +11,7 @@ import ( "reflect" "sync/atomic" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/kibana/config_reconcile.go b/pkg/controller/kibana/config_reconcile.go index 7ad6cab7fd..a033bb664b 100644 --- a/pkg/controller/kibana/config_reconcile.go +++ b/pkg/controller/kibana/config_reconcile.go @@ -8,7 +8,7 @@ import ( "context" "fmt" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/kibana/config_settings.go b/pkg/controller/kibana/config_settings.go index 0631fc5f46..a63460e4a3 100644 --- a/pkg/controller/kibana/config_settings.go +++ b/pkg/controller/kibana/config_settings.go @@ -11,7 +11,7 @@ import ( "github.com/elastic/go-ucfg" "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/kibana/controller.go b/pkg/controller/kibana/controller.go index dd64701487..7d4c2e2d48 100644 --- a/pkg/controller/kibana/controller.go +++ b/pkg/controller/kibana/controller.go @@ -10,7 +10,7 @@ import ( "sync/atomic" "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/kibana/driver.go b/pkg/controller/kibana/driver.go index 4c976edb3c..8d571ca4f4 100644 --- a/pkg/controller/kibana/driver.go +++ b/pkg/controller/kibana/driver.go @@ -10,7 +10,7 @@ import ( "hash/fnv" pkgerrors "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/maps/controller.go b/pkg/controller/maps/controller.go index 3ebf9f9a38..92cee032c6 100644 --- a/pkg/controller/maps/controller.go +++ b/pkg/controller/maps/controller.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/remoteca/controller.go b/pkg/controller/remoteca/controller.go index a2152f5183..fa9a152de3 100644 --- a/pkg/controller/remoteca/controller.go +++ b/pkg/controller/remoteca/controller.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/controller/remoteca/secret.go b/pkg/controller/remoteca/secret.go index a4ae53b096..f8e485e5ab 100644 --- a/pkg/controller/remoteca/secret.go +++ b/pkg/controller/remoteca/secret.go @@ -7,7 +7,7 @@ package remoteca import ( "context" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/controller/webhook/reconcile.go b/pkg/controller/webhook/reconcile.go index 82fa85b5ff..2d92b3ea45 100644 --- a/pkg/controller/webhook/reconcile.go +++ b/pkg/controller/webhook/reconcile.go @@ -8,7 +8,7 @@ import ( "context" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" diff --git a/pkg/controller/webhook/webhook_certificates_controller.go b/pkg/controller/webhook/webhook_certificates_controller.go index 6204d433e4..a342ca1f15 100644 --- a/pkg/controller/webhook/webhook_certificates_controller.go +++ b/pkg/controller/webhook/webhook_certificates_controller.go @@ -10,7 +10,7 @@ import ( "time" pkgerrors "github.com/pkg/errors" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/license/license.go b/pkg/license/license.go index c19582bf03..7784af4ff2 100644 --- a/pkg/license/license.go +++ b/pkg/license/license.go @@ -13,7 +13,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/license/reporter.go b/pkg/license/reporter.go index c1dcb8a1c8..00c27884bf 100644 --- a/pkg/license/reporter.go +++ b/pkg/license/reporter.go @@ -8,7 +8,7 @@ import ( "context" "time" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/elastic/cloud-on-k8s/pkg/controller/common/tracing" diff --git a/pkg/telemetry/telemetry.go b/pkg/telemetry/telemetry.go index b1cdc965de..d002e016ae 100644 --- a/pkg/telemetry/telemetry.go +++ b/pkg/telemetry/telemetry.go @@ -10,7 +10,7 @@ import ( "time" "github.com/ghodss/yaml" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/utils/log/log.go b/pkg/utils/log/log.go index 88ccdccd7c..c382349e24 100644 --- a/pkg/utils/log/log.go +++ b/pkg/utils/log/log.go @@ -12,7 +12,7 @@ import ( "github.com/go-logr/logr" "github.com/spf13/pflag" - "go.elastic.co/apm" + "go.elastic.co/apm/v2" "go.uber.org/zap" "go.uber.org/zap/zapcore" "k8s.io/klog/v2"