From cddaa6b978762e35ec668baa4db908ae70cc5b75 Mon Sep 17 00:00:00 2001 From: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:41:29 +0530 Subject: [PATCH] [otel] - Add Diagnostics Extension (#10141) * initial commit * timeout * fix tests * comments * error handling * test case * readme * gofmt * remove println * test * add cpu profile * remove telemetry for now. * remove redundant code * doc * fix npipe * Update internal/pkg/otel/extension/elasticdiagnostics/extension.go Co-authored-by: Craig MacKenzie * readme * readme * Update internal/pkg/otel/extension/elasticdiagnostics/extension.go Co-authored-by: Panos Koutsovasilis * mutex * comments * Update generated_component_test.go * Update generated_component_test.go * comments * test thorough * use eventuallyWith * test CI green * remove platforms --------- Co-authored-by: Craig MacKenzie Co-authored-by: Panos Koutsovasilis (cherry picked from commit cac88a467cfb7c394eb69ba91b7d73f99b8d88ca) # Conflicts: # NOTICE-fips.txt # NOTICE.txt # go.mod # internal/pkg/otel/README.md --- NOTICE-fips.txt | 527 ++++++++++++++++++ NOTICE.txt | 527 ++++++++++++++++++ go.mod | 75 +++ internal/pkg/otel/README.md | 16 + .../extension/elasticdiagnostics/README.md | 64 +++ .../extension/elasticdiagnostics/config.go | 26 + .../extension/elasticdiagnostics/extension.go | 245 ++++++++ .../elasticdiagnostics/extension_test.go | 125 +++++ .../extension/elasticdiagnostics/factory.go | 31 ++ .../generated_component_test.go | 97 ++++ .../internal/metadata/generated_status.go | 19 + .../elasticdiagnostics/metadata.yaml | 13 + .../extension/elasticdiagnostics/response.go | 12 + pkg/control/v2/client/dial.go | 4 +- pkg/control/v2/client/dial_windows.go | 4 +- 15 files changed, 1781 insertions(+), 4 deletions(-) create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/README.md create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/config.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/extension.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/extension_test.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/factory.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/generated_component_test.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/internal/metadata/generated_status.go create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/metadata.yaml create mode 100644 internal/pkg/otel/extension/elasticdiagnostics/response.go diff --git a/NOTICE-fips.txt b/NOTICE-fips.txt index f50854e1be3..12835225ce0 100644 --- a/NOTICE-fips.txt +++ b/NOTICE-fips.txt @@ -13270,6 +13270,218 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/comp limitations under the License. +-------------------------------------------------------------------------------- +Dependency : go.opentelemetry.io/collector/component/componenttest +Version: v0.135.0 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/component/componenttest@v0.135.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 [yyyy] [name of copyright owner] + + 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. + + -------------------------------------------------------------------------------- Dependency : go.opentelemetry.io/collector/confmap Version: v1.38.0 @@ -16238,6 +16450,218 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte limitations under the License. +-------------------------------------------------------------------------------- +Dependency : go.opentelemetry.io/collector/extension/extensiontest +Version: v0.135.0 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/extension/extensiontest@v0.135.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 [yyyy] [name of copyright owner] + + 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. + + -------------------------------------------------------------------------------- Dependency : go.opentelemetry.io/collector/extension/memorylimiterextension Version: v0.132.0 @@ -18387,6 +18811,66 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +Dependency : go.yaml.in/yaml/v3 +Version: v3.0.4 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.yaml.in/yaml/v3@v3.0.4/LICENSE: + + +This project is covered by two different licenses: MIT and Apache. + +#### MIT License #### + +The following files were ported to Go from C files of libyaml, and thus +are still covered by their original MIT license, with the additional +copyright staring in 2011 when the project was ported over: + + apic.go emitterc.go parserc.go readerc.go scannerc.go + writerc.go yamlh.go yamlprivateh.go + +Copyright (c) 2006-2010 Kirill Simonov +Copyright (c) 2006-2011 Kirill Simonov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +### Apache License ### + +All the remaining project files are covered by the Apache license: + +Copyright (c) 2011-2019 Canonical Ltd + +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. + + -------------------------------------------------------------------------------- Dependency : golang.org/x/crypto Version: v0.41.0 @@ -69213,6 +69697,7 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/clie -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.opentelemetry.io/collector/component/componenttest Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -69425,6 +69910,8 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/comp -------------------------------------------------------------------------------- +======= +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) Dependency : go.opentelemetry.io/collector/config/configauth Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -74725,6 +75212,7 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.opentelemetry.io/collector/extension/extensiontest Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -74937,6 +75425,8 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte -------------------------------------------------------------------------------- +======= +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) Dependency : go.opentelemetry.io/collector/extension/xextension Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -85781,6 +86271,7 @@ Contents of probable licence file $GOMODCACHE/go.yaml.in/yaml/v2@v2.4.2/LICENSE: -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.yaml.in/yaml/v3 Version: v3.0.4 Licence type (autodetected): MIT @@ -85838,6 +86329,42 @@ 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. +======= +Dependency : golang.org/x/arch +Version: v0.20.0 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/golang.org/x/arch@v0.20.0/LICENSE: + +Copyright 2015 The Go Authors. + +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 LLC 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. +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) -------------------------------------------------------------------------------- diff --git a/NOTICE.txt b/NOTICE.txt index 497cd3ba472..4f66f177723 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -13903,6 +13903,218 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/comp limitations under the License. +-------------------------------------------------------------------------------- +Dependency : go.opentelemetry.io/collector/component/componenttest +Version: v0.135.0 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/component/componenttest@v0.135.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 [yyyy] [name of copyright owner] + + 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. + + -------------------------------------------------------------------------------- Dependency : go.opentelemetry.io/collector/confmap Version: v1.38.0 @@ -16871,6 +17083,218 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte limitations under the License. +-------------------------------------------------------------------------------- +Dependency : go.opentelemetry.io/collector/extension/extensiontest +Version: v0.135.0 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/extension/extensiontest@v0.135.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 [yyyy] [name of copyright owner] + + 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. + + -------------------------------------------------------------------------------- Dependency : go.opentelemetry.io/collector/extension/memorylimiterextension Version: v0.132.0 @@ -19020,6 +19444,66 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------------------- +Dependency : go.yaml.in/yaml/v3 +Version: v3.0.4 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/go.yaml.in/yaml/v3@v3.0.4/LICENSE: + + +This project is covered by two different licenses: MIT and Apache. + +#### MIT License #### + +The following files were ported to Go from C files of libyaml, and thus +are still covered by their original MIT license, with the additional +copyright staring in 2011 when the project was ported over: + + apic.go emitterc.go parserc.go readerc.go scannerc.go + writerc.go yamlh.go yamlprivateh.go + +Copyright (c) 2006-2010 Kirill Simonov +Copyright (c) 2006-2011 Kirill Simonov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +### Apache License ### + +All the remaining project files are covered by the Apache license: + +Copyright (c) 2011-2019 Canonical Ltd + +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. + + -------------------------------------------------------------------------------- Dependency : golang.org/x/crypto Version: v0.41.0 @@ -79438,6 +79922,7 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/clie -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.opentelemetry.io/collector/component/componenttest Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -79650,6 +80135,8 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/comp -------------------------------------------------------------------------------- +======= +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) Dependency : go.opentelemetry.io/collector/config/configauth Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -84950,6 +85437,7 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.opentelemetry.io/collector/extension/extensiontest Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -85162,6 +85650,8 @@ Contents of probable licence file $GOMODCACHE/go.opentelemetry.io/collector/exte -------------------------------------------------------------------------------- +======= +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) Dependency : go.opentelemetry.io/collector/extension/xextension Version: v0.132.0 Licence type (autodetected): Apache-2.0 @@ -96306,6 +96796,7 @@ Contents of probable licence file $GOMODCACHE/go.yaml.in/yaml/v2@v2.4.2/LICENSE: -------------------------------------------------------------------------------- +<<<<<<< HEAD Dependency : go.yaml.in/yaml/v3 Version: v3.0.4 Licence type (autodetected): MIT @@ -96363,6 +96854,42 @@ 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. +======= +Dependency : golang.org/x/arch +Version: v0.20.0 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/golang.org/x/arch@v0.20.0/LICENSE: + +Copyright 2015 The Go Authors. + +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 LLC 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. +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) -------------------------------------------------------------------------------- diff --git a/go.mod b/go.mod index 5b5cc58a099..81107462877 100644 --- a/go.mod +++ b/go.mod @@ -78,12 +78,31 @@ require ( go.elastic.co/apm/v2 v2.7.1 go.elastic.co/ecszap v1.0.3 go.elastic.co/go-licence-detector v0.7.0 +<<<<<<< HEAD go.opentelemetry.io/collector/component/componentstatus v0.132.0 go.opentelemetry.io/collector/connector/forwardconnector v0.132.0 go.opentelemetry.io/collector/pipeline v1.38.0 go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.132.0 go.opentelemetry.io/collector/receiver/nopreceiver v0.132.0 +======= + go.opentelemetry.io/collector/component/componentstatus v0.135.0 + go.opentelemetry.io/collector/component/componenttest v0.135.0 + go.opentelemetry.io/collector/connector/forwardconnector v0.135.0 + go.opentelemetry.io/collector/exporter/debugexporter v0.135.0 + go.opentelemetry.io/collector/exporter/nopexporter v0.135.0 + go.opentelemetry.io/collector/exporter/otlpexporter v0.135.0 + go.opentelemetry.io/collector/exporter/otlphttpexporter v0.135.0 + go.opentelemetry.io/collector/extension/extensiontest v0.135.0 + go.opentelemetry.io/collector/extension/memorylimiterextension v0.135.0 + go.opentelemetry.io/collector/pipeline v1.41.0 + go.opentelemetry.io/collector/processor/batchprocessor v0.135.0 + go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.135.0 + go.opentelemetry.io/collector/receiver/nopreceiver v0.135.0 + go.opentelemetry.io/collector/receiver/otlpreceiver v0.135.0 + go.opentelemetry.io/ebpf-profiler v0.0.202536 +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) go.uber.org/zap v1.27.0 + go.yaml.in/yaml/v3 v3.0.4 golang.org/x/crypto v0.41.0 golang.org/x/exp v0.0.0-20250215185904-eff6e970281f golang.org/x/mod v0.27.0 @@ -634,6 +653,7 @@ require ( go.etcd.io/bbolt v1.4.2 // indirect go.mongodb.org/mongo-driver v1.17.4 // indirect go.opencensus.io v0.24.0 // indirect +<<<<<<< HEAD go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/collector v0.132.0 // indirect go.opentelemetry.io/collector/client v1.38.0 // indirect @@ -684,6 +704,57 @@ require ( go.opentelemetry.io/collector/receiver/xreceiver v0.132.0 // indirect go.opentelemetry.io/collector/scraper v0.132.0 // indirect go.opentelemetry.io/collector/scraper/scraperhelper v0.132.0 // indirect +======= + go.opentelemetry.io/auto/sdk v1.2.0 // indirect + go.opentelemetry.io/collector v0.135.0 // indirect + go.opentelemetry.io/collector/client v1.41.0 // indirect + go.opentelemetry.io/collector/config/configauth v0.135.0 // indirect + go.opentelemetry.io/collector/config/configcompression v1.41.0 // indirect + go.opentelemetry.io/collector/config/configgrpc v0.135.0 // indirect + go.opentelemetry.io/collector/config/confighttp v0.135.0 // indirect + go.opentelemetry.io/collector/config/configmiddleware v1.41.0 // indirect + go.opentelemetry.io/collector/config/confignet v1.41.0 // indirect + go.opentelemetry.io/collector/config/configopaque v1.41.0 // indirect + go.opentelemetry.io/collector/config/configoptional v0.135.0 // indirect + go.opentelemetry.io/collector/config/configretry v1.41.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.135.0 // indirect + go.opentelemetry.io/collector/config/configtls v1.41.0 // indirect + go.opentelemetry.io/collector/confmap/xconfmap v0.135.0 // indirect + go.opentelemetry.io/collector/connector/connectortest v0.135.0 // indirect + go.opentelemetry.io/collector/connector/xconnector v0.135.0 // indirect + go.opentelemetry.io/collector/consumer v1.41.0 // indirect + go.opentelemetry.io/collector/consumer/consumererror v0.135.0 // indirect + go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.135.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.135.0 // indirect + go.opentelemetry.io/collector/consumer/xconsumer v0.135.0 // indirect + go.opentelemetry.io/collector/exporter/exporterhelper v0.135.0 // indirect + go.opentelemetry.io/collector/exporter/exporterhelper/xexporterhelper v0.135.0 // indirect + go.opentelemetry.io/collector/exporter/exportertest v0.135.0 // indirect + go.opentelemetry.io/collector/exporter/xexporter v0.135.0 // indirect + go.opentelemetry.io/collector/extension/extensionauth v1.41.0 // indirect + go.opentelemetry.io/collector/extension/extensioncapabilities v0.135.0 // indirect + go.opentelemetry.io/collector/extension/extensionmiddleware v0.135.0 // indirect + go.opentelemetry.io/collector/extension/xextension v0.135.0 // indirect + go.opentelemetry.io/collector/filter v0.135.0 // indirect + go.opentelemetry.io/collector/internal/fanoutconsumer v0.135.0 // indirect + go.opentelemetry.io/collector/internal/memorylimiter v0.135.0 // indirect + go.opentelemetry.io/collector/internal/sharedcomponent v0.135.0 // indirect + go.opentelemetry.io/collector/internal/telemetry v0.135.0 // indirect + go.opentelemetry.io/collector/pdata v1.41.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.135.0 // indirect + go.opentelemetry.io/collector/pdata/testdata v0.135.0 // indirect + go.opentelemetry.io/collector/pdata/xpdata v0.135.0 // indirect + go.opentelemetry.io/collector/pipeline/xpipeline v0.135.0 // indirect + go.opentelemetry.io/collector/processor/processorhelper v0.135.0 // indirect + go.opentelemetry.io/collector/processor/processorhelper/xprocessorhelper v0.135.0 // indirect + go.opentelemetry.io/collector/processor/processortest v0.135.0 // indirect + go.opentelemetry.io/collector/processor/xprocessor v0.135.0 // indirect + go.opentelemetry.io/collector/receiver/receiverhelper v0.135.0 // indirect + go.opentelemetry.io/collector/receiver/receivertest v0.135.0 // indirect + go.opentelemetry.io/collector/receiver/xreceiver v0.135.0 // indirect + go.opentelemetry.io/collector/scraper v0.135.0 // indirect + go.opentelemetry.io/collector/scraper/scraperhelper v0.135.0 // indirect +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) go.opentelemetry.io/collector/semconv v0.128.1-0.20250610090210-188191247685 // indirect go.opentelemetry.io/collector/service v0.132.0 // indirect go.opentelemetry.io/collector/service/hostcapabilities v0.132.0 // indirect @@ -721,7 +792,11 @@ require ( go.uber.org/ratelimit v0.3.1 // indirect go.uber.org/zap/exp v0.3.0 // indirect go.yaml.in/yaml/v2 v2.4.2 // indirect +<<<<<<< HEAD go.yaml.in/yaml/v3 v3.0.4 // indirect +======= + golang.org/x/arch v0.20.0 // indirect +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) golang.org/x/oauth2 v0.30.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect gonum.org/v1/gonum v0.16.0 // indirect diff --git a/internal/pkg/otel/README.md b/internal/pkg/otel/README.md index 2b567f07667..ad7022ff43b 100644 --- a/internal/pkg/otel/README.md +++ b/internal/pkg/otel/README.md @@ -87,6 +87,7 @@ This section provides a summary of components included in the Elastic Distributi | Component | Version | |---|---| +<<<<<<< HEAD | [apikeyauthextension](https://github.com/elastic/opentelemetry-collector-components/blob/extension/apikeyauthextension/v0.4.1/extension/apikeyauthextension/README.md) | v0.4.1 | | [apmconfigextension](https://github.com/elastic/opentelemetry-collector-components/blob/extension/apmconfigextension/v0.6.0/extension/apmconfigextension/README.md) | v0.6.0 | | [bearertokenauthextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/bearertokenauthextension/v0.132.0/extension/bearertokenauthextension/README.md) | v0.132.0 | @@ -97,6 +98,21 @@ This section provides a summary of components included in the Elastic Distributi | [k8sobserver](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/observer/k8sobserver/v0.132.0/extension/observer/k8sobserver/README.md) | v0.132.0 | | [memorylimiterextension](https://github.com/open-telemetry/opentelemetry-collector/blob/extension/memorylimiterextension/v0.132.0/extension/memorylimiterextension/README.md) | v0.132.0 | | [pprofextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/pprofextension/v0.132.0/extension/pprofextension/README.md) | v0.132.0 | +======= +| [apikeyauthextension](https://github.com/elastic/opentelemetry-collector-components/blob/extension/apikeyauthextension/v0.5.0/extension/apikeyauthextension/README.md) | v0.5.0 | +| [apmconfigextension](https://github.com/elastic/opentelemetry-collector-components/blob/extension/apmconfigextension/v0.7.0/extension/apmconfigextension/README.md) | v0.7.0 | +| [bearertokenauthextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/bearertokenauthextension/v0.135.0/extension/bearertokenauthextension/README.md) | v0.135.0 | +| [beatsauthextension](https://github.com/elastic/opentelemetry-collector-components/blob/extension/beatsauthextension/v0.3.0/extension/beatsauthextension/README.md) | v0.3.0 | +| [extensiontest](https://github.com/open-telemetry/opentelemetry-collector/blob/extension/extensiontest/v0.135.0/extension/extensiontest/README.md) | v0.135.0 | +| [filestorage](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/storage/filestorage/v0.135.0/extension/storage/filestorage/README.md) | v0.135.0 | +| [headerssetterextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/headerssetterextension/v0.135.0/extension/headerssetterextension/README.md) | v0.135.0 | +| [healthcheckextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/healthcheckextension/v0.135.0/extension/healthcheckextension/README.md) | v0.135.0 | +| [healthcheckv2extension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/healthcheckv2extension/v0.135.0/extension/healthcheckv2extension/README.md) | v0.135.0 | +| [k8sleaderelector](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/k8sleaderelector/v0.135.0/extension/k8sleaderelector/README.md) | v0.135.0 | +| [k8sobserver](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/observer/k8sobserver/v0.135.0/extension/observer/k8sobserver/README.md) | v0.135.0 | +| [memorylimiterextension](https://github.com/open-telemetry/opentelemetry-collector/blob/extension/memorylimiterextension/v0.135.0/extension/memorylimiterextension/README.md) | v0.135.0 | +| [pprofextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/extension/pprofextension/v0.135.0/extension/pprofextension/README.md) | v0.135.0 | +>>>>>>> cac88a467 ([otel] - Add Diagnostics Extension (#10141)) ### Connectors diff --git a/internal/pkg/otel/extension/elasticdiagnostics/README.md b/internal/pkg/otel/extension/elasticdiagnostics/README.md new file mode 100644 index 00000000000..e715a04f548 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/README.md @@ -0,0 +1,64 @@ +# elasticdiagnosticsextension + +`elasticdiagnosticsextension` is an internal package for peforming diagnostics and is used in conjunction with EDOT. +The extension is designed to return diagnostics in a format compatible with the [ActionDiagnosticUnitResult](https://github.com/elastic/elastic-agent-client/blob/888026ef85e1c9190fe76eb158cf21d9c9c02920/elastic-agent-client.proto#L424-L437) type defined in the control protocol. + + +## Configuration + +The extension accepts the `endpoint` as a sole parameter. The endpoint should begin with a valid protocol and it valid values are `unix` and `npipe` for now. Here are a few examples: + +- `unix:///tmp/elastic-agent/xyz.soc` +- `npipe:///elastic-agent` + +## Features + +- Acts as a registrar and keeps track of common diagnostic hooks. +- Collects profiles using `runtime/pprof`. +- Collects internal telemetry exposed by the OTeL Collector. +- Implements the `extensioncapabilities.ConfigWatcher` interface and stores the latest configuration of the running collector. +- Listens for diagnostic requests and provides diagnostic data. + +## Design + +### Diagnostic hooks: +- Individual beats register custom diagnostic hooks and these hooks are called when we run the elastic-agent diagnostics command. +- Our extension stores these hooks and executes them everytime it gets a "diagnostics" request. + +### Request/Response format: +- This extension runs an HTTP server and listens to new requests on `/diagnostics` path. +- The following query parameters are optional: + - `cpu` + - If `true`, the extension will also collect cpu profile of EDOT. + - By default, the extension doesn't collect the CPU profile unless explicitly specified. + - `cpuduration`: + - Specifies the time duration over which the CPU profile should be collected. + - Valid time units are `ns`, `us`, `ms`, `s`, `m`, `h` + - Default: `30s`. +- The response format is defined in [response.go](./response.go). + - `GlobalDiagnostics`: Data related to the overall process: + 1. Profiles. + 2. Internal telemetry. + 3. latest collector configuration. + - `ComponentDiagnostics`: Data from individual receivers, collected via registered diagnostic hooks. + +### Interaction with Elastic-Agent service in hybrid mode. + +- When the user triggers the diagnostic request, EDOT diagnostics are injected at two levels: + 1. At top-Level: + - When `DiagnosticAgent()` is called in [server.go](https://github.com/elastic/elastic-agent/blob/710c49f45433e2f136a6e41cae980c1aa37dabdd/pkg/control/v2/server/server.go#L197). + - Diagnostics are captured at the global level and stored under the `edot/*` directory in the resulting ZIP archive. + 2. At component-level: + - When `otelMgr.PerformComponentsDiagnostics()` is called in [coordinator.go](https://github.com/elastic/elastic-agent/blob/710c49f45433e2f136a6e41cae980c1aa37dabdd/internal/pkg/agent/application/coordinator/coordinator.go#L863). + - Diagnostics are added per component and stored under the `components/{comp}/*` directory in the resulting ZIP archive. + +#### Diagram + +```mermaid +graph LR + A[elastic-agent install ...] --> B[Runs the service in hybrid mode
and we inject agentdiagnosticsextension] + B -->|listens to| D[edot-diagnostics-extension.sock] + + C[elastic-agent diagnostics] --> E[Extracts diagnostics socket path via the binary] + E -->|requests OTeL diagnostics| D +``` \ No newline at end of file diff --git a/internal/pkg/otel/extension/elasticdiagnostics/config.go b/internal/pkg/otel/extension/elasticdiagnostics/config.go new file mode 100644 index 00000000000..dfe12f23f28 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/config.go @@ -0,0 +1,26 @@ +// 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 elasticdiagnostics + +import ( + "errors" + + "go.opentelemetry.io/collector/component" +) + +type Config struct { + Endpoint string `mapstructure:"endpoint"` +} + +func createDefaultConfig() component.Config { + return &Config{} +} + +func (c *Config) Validate() error { + if c.Endpoint == "" { + return errors.New("endpoint is a required field") + } + return nil +} diff --git a/internal/pkg/otel/extension/elasticdiagnostics/extension.go b/internal/pkg/otel/extension/elasticdiagnostics/extension.go new file mode 100644 index 00000000000..98e6bfa5f8c --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/extension.go @@ -0,0 +1,245 @@ +// 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 elasticdiagnostics + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "net" + "net/http" + "runtime/pprof" + "sync" + "time" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap" + "go.uber.org/zap" + "go.yaml.in/yaml/v3" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/elastic/elastic-agent-client/v7/pkg/proto" + "github.com/elastic/elastic-agent-libs/logp" + "github.com/elastic/elastic-agent/internal/pkg/diagnostics" + "github.com/elastic/elastic-agent/pkg/ipc" +) + +var ( + _ component.Component = (*diagnosticsExtension)(nil) +) + +type diagHook struct { + description string + filename string + contentType string + hook func() []byte +} + +type diagnosticsExtension struct { + listener net.Listener + server *http.Server + logger *zap.Logger + logp *logp.Logger + + diagnosticsConfig *Config + collectorConfig *confmap.Conf + componentHooks map[string][]*diagHook + globalHooks map[string]*diagHook + + mx sync.Mutex + hooksMtx sync.Mutex + configMtx sync.Mutex +} + +func (d *diagnosticsExtension) Start(ctx context.Context, host component.Host) error { + d.mx.Lock() + defer d.mx.Unlock() + var err error + + d.logp, err = logp.NewZapLogger(d.logger) + if err != nil { + // NewZapLogger always returns nil error, so this shouldn't happen. + return fmt.Errorf("failed to create logp.Logger from zap logger: %w", err) + } + + d.registerGlobalDiagnostics() + + d.listener, err = ipc.CreateListener(d.logp, d.diagnosticsConfig.Endpoint) + if err != nil { + return fmt.Errorf("error creating listener: %w", err) + } + + mux := http.NewServeMux() + mux.Handle("/diagnostics", d) + + d.server = &http.Server{ + Handler: mux, + ReadHeaderTimeout: 30 * time.Second, + } + go func() { + if err := d.server.Serve(d.listener); err != nil && !errors.Is(err, http.ErrServerClosed) { + d.logger.Error("HTTP server error", zap.Error(err)) + } + }() + d.logger.Info("Diagnostics extension started", zap.String("address", d.listener.Addr().String())) + return nil +} + +func (d *diagnosticsExtension) Shutdown(ctx context.Context) error { + d.mx.Lock() + defer d.mx.Unlock() + if d.server == nil { + return nil + } + if err := d.server.Shutdown(ctx); err != nil { + return err + } + ipc.CleanupListener(d.logp, d.diagnosticsConfig.Endpoint) + return nil +} + +func (d *diagnosticsExtension) registerGlobalDiagnostics() { + d.globalHooks["collector_config"] = &diagHook{ + description: "full collector configuration", + filename: "edot/otel-merged-actual.yaml", + contentType: "application/yaml", + hook: func() []byte { + d.configMtx.Lock() + defer d.configMtx.Unlock() + if d.collectorConfig == nil { + return []byte("no active OTel Configuration") + } + b, err := yaml.Marshal(d.collectorConfig.ToStringMap()) + if err != nil { + return fmt.Appendf(nil, "error: failed to convert to yaml: %v", err) + } + return b + }, + } + + // register basic profiles. + for _, profile := range []string{"goroutine", "heap", "allocs", "mutex", "threadcreate", "block"} { + d.globalHooks[profile] = &diagHook{ + description: fmt.Sprintf("%s profile of the collector", profile), + filename: fmt.Sprintf("edot/%s.profile.gz", profile), + contentType: "application/octet-stream", + hook: func() []byte { + var buf bytes.Buffer + err := pprof.Lookup(profile).WriteTo(&buf, 0) + if err != nil { + return fmt.Appendf(nil, "error: failed to get %s profile: %v", profile, err) + } + return buf.Bytes() + }, + } + } +} + +func (d *diagnosticsExtension) NotifyConfig(ctx context.Context, conf *confmap.Conf) error { + d.configMtx.Lock() + defer d.configMtx.Unlock() + d.collectorConfig = conf + return nil +} + +// RegisterDiagnosticHook API exposes the ability for beat receivers to register their hooks. +// NOTE: Changing the function signature will require changes to libbeat and beatreceivers. Proceed with caution. +func (d *diagnosticsExtension) RegisterDiagnosticHook(componentName string, description string, filename string, contentType string, hook func() []byte) { + d.hooksMtx.Lock() + defer d.hooksMtx.Unlock() + if _, ok := d.componentHooks[componentName]; ok { + d.componentHooks[componentName] = append(d.componentHooks[componentName], &diagHook{ + description: description, + filename: filename, + contentType: contentType, + hook: hook, + }) + } else { + d.componentHooks[componentName] = []*diagHook{ + { + description: description, + filename: filename, + contentType: contentType, + hook: hook, + }, + } + } +} + +func (d *diagnosticsExtension) ServeHTTP(w http.ResponseWriter, req *http.Request) { + d.hooksMtx.Lock() + defer d.hooksMtx.Unlock() + componentResults := make([]*proto.ActionDiagnosticUnitResult, 0) + for name, hooks := range d.componentHooks { + for _, hook := range hooks { + componentResults = append(componentResults, &proto.ActionDiagnosticUnitResult{ + Name: name, + Filename: hook.filename, + ContentType: hook.contentType, + Description: hook.description, + Content: hook.hook(), + Generated: timestamppb.Now(), + }) + } + } + + globalResults := make([]*proto.ActionDiagnosticUnitResult, 0) + for name, hook := range d.globalHooks { + globalResults = append(globalResults, &proto.ActionDiagnosticUnitResult{ + Name: name, + Filename: hook.filename, + ContentType: hook.contentType, + Description: hook.description, + Content: hook.hook(), + Generated: timestamppb.Now(), + }) + } + + // only add a CPU profile if requested via query parameter. + if req.URL.Query().Get("cpu") == "true" { + diagCPUDuration := diagnostics.DiagCPUDuration + + // check if cpuduration parameter is set, if so override the default duration + // if parsing fails, log the error and use the default duration + if req.URL.Query().Get("cpuduration") != "" { + var err error + diagCPUDuration, err = time.ParseDuration(req.URL.Query().Get("cpuduration")) + if err != nil { + d.logger.Error("Failed parsing cpuduration parameter, using default", zap.String("cpuduration", req.URL.Query().Get("cpuduration")), zap.Error(err)) + diagCPUDuration = diagnostics.DiagCPUDuration + } + } + cpuProfile, err := diagnostics.CreateCPUProfile(req.Context(), diagCPUDuration) + if err != nil { + d.logger.Error("Failed creating CPU profile", zap.Error(err)) + } + globalResults = append(globalResults, &proto.ActionDiagnosticUnitResult{ + Name: "cpu", + Filename: "edot/cpu.profile.gz", + ContentType: "application/octet-stream", + Description: "CPU profile of the collector", + Content: cpuProfile, + }) + } + + b, err := json.Marshal(Response{ + GlobalDiagnostics: globalResults, + ComponentDiagnostics: componentResults, + }) + w.Header().Add("content-type", "application/json") + if err != nil { + d.logger.Error("Failed marshaling response", zap.Error(err)) + w.WriteHeader(500) + if _, err := fmt.Fprintf(w, "{'error':'%v'}", err); err != nil { + d.logger.Error("Failed writing response to client.", zap.Error(err)) + } + return + } + if _, err := w.Write(b); err != nil { + d.logger.Error("Failed writing response to client.", zap.Error(err)) + } +} diff --git a/internal/pkg/otel/extension/elasticdiagnostics/extension_test.go b/internal/pkg/otel/extension/elasticdiagnostics/extension_test.go new file mode 100644 index 00000000000..0857a05d9c5 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/extension_test.go @@ -0,0 +1,125 @@ +// 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 elasticdiagnostics + +import ( + "context" + "encoding/json" + "io" + "net" + "net/http" + "strings" + "testing" + "time" + + "github.com/google/pprof/profile" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/extension" + "go.uber.org/zap" + + "github.com/elastic/elastic-agent/internal/pkg/otel/extension/elasticdiagnostics/internal/metadata" + "github.com/elastic/elastic-agent/pkg/control/v2/client" + "github.com/elastic/elastic-agent/pkg/utils" +) + +func TestExtension(t *testing.T) { + temp := t.TempDir() + config := createDefaultConfig().(*Config) + config.Endpoint = utils.SocketURLWithFallback("edot.sock", temp) + + ext, err := NewFactory().Create(context.Background(), extension.Settings{ + TelemetrySettings: component.TelemetrySettings{ + Logger: zap.NewNop(), + }, + ID: component.NewID(metadata.Type), + }, config) + require.NoError(t, err) + require.NotNil(t, ext) + + require.NoError(t, ext.Start(context.Background(), componenttest.NewNopHost())) + defer func() { + require.NoError(t, ext.Shutdown(context.Background())) + }() + + // mock a few calls to RegisterDiagnosticHook + diagExt := ext.(*diagnosticsExtension) + diagExt.RegisterDiagnosticHook("test_component", + "Test Hook", + "test.json", + "application/json", + func() []byte { + return []byte("diagnostic data") + }, + ) + + diagExt.RegisterDiagnosticHook("test_component2", + "Test Hook2", + "test2.json", + "application/json", + func() []byte { + return []byte("diagnostic data 2") + }, + ) + + tr := &http.Transport{ + DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { + return client.Dialer(ctx, config.Endpoint) + }, + } + client := &http.Client{Transport: tr} + + require.EventuallyWithT(t, func(collect *assert.CollectT) { + req, err := http.NewRequest(http.MethodGet, "http://localhost/diagnostics?cpu=true&cpuduration=5s", nil) + require.NoError(collect, err) + resp, err := client.Do(req.WithContext(context.Background())) + require.NoError(collect, err) + require.Equal(collect, http.StatusOK, resp.StatusCode) + + b, err := io.ReadAll(resp.Body) + require.NoError(collect, err) + res := Response{} + + // test that the response can be unmarshalled + require.NoErrorf(collect, json.Unmarshal(b, &res), "failed to unmarshal response: %s", string(b)) + require.NotEmpty(collect, res.GlobalDiagnostics) + require.NotEmpty(collect, res.ComponentDiagnostics) + foundCPU := false + for _, global := range res.GlobalDiagnostics { + if global.Name == "cpu" { + foundCPU = true + break + } + if strings.HasSuffix(global.Filename, "profile.gz") { + verifyPprof(t, global.Content) + } + } + require.True(collect, foundCPU, "cpu.pprof not found in global diagnostics") + + for _, comp := range res.ComponentDiagnostics { + switch comp.Name { + case "test_component": + require.Equal(collect, "test.json", comp.Filename) + require.Equal(collect, "application/json", comp.ContentType) + require.Equal(collect, "Test Hook", comp.Description) + require.Equal(collect, []byte("diagnostic data"), comp.Content) + case "test_component2": + require.Equal(collect, "test2.json", comp.Filename) + require.Equal(collect, "application/json", comp.ContentType) + require.Equal(collect, "Test Hook2", comp.Description) + require.Equal(collect, []byte("diagnostic data 2"), comp.Content) + } + } + require.NoError(collect, resp.Body.Close()) + }, 10*time.Second, 1*time.Millisecond, "extension did not start in time") +} + +func verifyPprof(t *testing.T, content []byte) { + prof, err := profile.ParseData(content) + require.NoError(t, err) + require.NotNil(t, prof) +} diff --git a/internal/pkg/otel/extension/elasticdiagnostics/factory.go b/internal/pkg/otel/extension/elasticdiagnostics/factory.go new file mode 100644 index 00000000000..f834610fe20 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/factory.go @@ -0,0 +1,31 @@ +// 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 elasticdiagnostics + +import ( + "context" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/extension" + + "github.com/elastic/elastic-agent/internal/pkg/otel/extension/elasticdiagnostics/internal/metadata" +) + +var ( + DiagnosticsExtensionID component.Type = metadata.Type +) + +func NewFactory() extension.Factory { + return extension.NewFactory(metadata.Type, createDefaultConfig, newExtension, component.StabilityLevelDevelopment) +} + +func newExtension(ctx context.Context, set extension.Settings, cfg component.Config) (extension.Extension, error) { + return &diagnosticsExtension{ + diagnosticsConfig: cfg.(*Config), + logger: set.Logger.Named("elastic_diagnostics"), + componentHooks: make(map[string][]*diagHook), + globalHooks: make(map[string]*diagHook), + }, nil +} diff --git a/internal/pkg/otel/extension/elasticdiagnostics/generated_component_test.go b/internal/pkg/otel/extension/elasticdiagnostics/generated_component_test.go new file mode 100644 index 00000000000..ebfb458dff3 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/generated_component_test.go @@ -0,0 +1,97 @@ +// 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 elasticdiagnostics + +import ( + "context" + "fmt" + "runtime" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/confmap/confmaptest" + "go.opentelemetry.io/collector/extension/extensiontest" +) + +var typ = component.MustNewType("elastic_diagnostics") + +func TestComponentFactoryType(t *testing.T) { + require.Equal(t, typ, NewFactory().Type()) +} + +func TestComponentConfigStruct(t *testing.T) { + require.NoError(t, componenttest.CheckConfigStruct(NewFactory().CreateDefaultConfig())) +} + +func TestComponentLifecycle(t *testing.T) { + factory := NewFactory() + + cm, err := confmaptest.LoadConf("metadata.yaml") + require.NoError(t, err) + cfg := factory.CreateDefaultConfig().(*Config) + sub, err := cm.Sub("tests::config") + require.NoError(t, err) + require.NoError(t, sub.Unmarshal(&cfg)) + if runtime.GOOS == "windows" { + // Use a different endpoint on Windows as /tmp/test.sock is not valid + cfg.Endpoint = fmt.Sprintf("npipe://%s", cfg.Endpoint) + } + t.Run("shutdown", func(t *testing.T) { + e, err := factory.Create(context.Background(), extensiontest.NewNopSettings(typ), cfg) + require.NoError(t, err) + err = e.Shutdown(context.Background()) + require.NoError(t, err) + }) + t.Run("lifecycle", func(t *testing.T) { + require.EventuallyWithT(t, func(collect *assert.CollectT) { + firstExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(typ), cfg) + require.NoError(collect, err) + require.NoError(collect, firstExt.Start(context.Background(), newMdatagenNopHost())) + require.NoError(collect, firstExt.Shutdown(context.Background())) + }, 5*time.Second, 100*time.Millisecond) + + require.EventuallyWithT(t, func(collect *assert.CollectT) { + secondExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(typ), cfg) + require.NoError(collect, err) + require.NoError(collect, secondExt.Start(context.Background(), newMdatagenNopHost())) + require.NoError(collect, secondExt.Shutdown(context.Background())) + }, 5*time.Second, 100*time.Millisecond) + }) + t.Run("shutdown twice", func(t *testing.T) { + require.EventuallyWithT(t, func(collect *assert.CollectT) { + firstExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(typ), cfg) + require.NoError(collect, err) + require.NoError(collect, firstExt.Start(context.Background(), newMdatagenNopHost())) + require.NoError(collect, firstExt.Shutdown(context.Background())) + require.NoError(collect, firstExt.Shutdown(context.Background())) + }, 5*time.Second, 100*time.Millisecond) + }) + t.Run("shutdown twice - without start", func(t *testing.T) { + firstExt, err := factory.Create(context.Background(), extensiontest.NewNopSettings(typ), cfg) + require.NoError(t, err) + require.NoError(t, firstExt.Shutdown(context.Background())) + require.NoError(t, firstExt.Shutdown(context.Background())) + }) +} + +var _ component.Host = (*mdatagenNopHost)(nil) + +type mdatagenNopHost struct{} + +func newMdatagenNopHost() component.Host { + return &mdatagenNopHost{} +} + +func (mnh *mdatagenNopHost) GetExtensions() map[component.ID]component.Component { + return nil +} + +func (mnh *mdatagenNopHost) GetFactory(_ component.Kind, _ component.Type) component.Factory { + return nil +} diff --git a/internal/pkg/otel/extension/elasticdiagnostics/internal/metadata/generated_status.go b/internal/pkg/otel/extension/elasticdiagnostics/internal/metadata/generated_status.go new file mode 100644 index 00000000000..32822a0a92b --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/internal/metadata/generated_status.go @@ -0,0 +1,19 @@ +// 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. + +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +var ( + Type = component.MustNewType("elastic_diagnostics") +) + +const ( + ExtensionStability = component.StabilityLevelDevelopment +) diff --git a/internal/pkg/otel/extension/elasticdiagnostics/metadata.yaml b/internal/pkg/otel/extension/elasticdiagnostics/metadata.yaml new file mode 100644 index 00000000000..544d821ded1 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/metadata.yaml @@ -0,0 +1,13 @@ +type: elastic_diagnostics +github_project: elastic/elastic-agent + +status: + class: extension + stability: + development: [extension] + codeowners: + active: [VihasMakwana] + +tests: + config: + endpoint: /tmp/test.sock diff --git a/internal/pkg/otel/extension/elasticdiagnostics/response.go b/internal/pkg/otel/extension/elasticdiagnostics/response.go new file mode 100644 index 00000000000..3a5f92a0f98 --- /dev/null +++ b/internal/pkg/otel/extension/elasticdiagnostics/response.go @@ -0,0 +1,12 @@ +// 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 elasticdiagnostics + +import "github.com/elastic/elastic-agent-client/v7/pkg/proto" + +type Response struct { + ComponentDiagnostics []*proto.ActionDiagnosticUnitResult `json:"diagnostics,omitempty"` + GlobalDiagnostics []*proto.ActionDiagnosticUnitResult `json:"global_diagnostics,omitempty"` +} diff --git a/pkg/control/v2/client/dial.go b/pkg/control/v2/client/dial.go index 7647a4c9cee..3e9a2d40ab1 100644 --- a/pkg/control/v2/client/dial.go +++ b/pkg/control/v2/client/dial.go @@ -18,13 +18,13 @@ import ( func dialContext(ctx context.Context, address string, maxMsgSize int, opts ...grpc.DialOption) (*grpc.ClientConn, error) { opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithContextDialer(dialer), + grpc.WithContextDialer(Dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)), ) return grpc.DialContext(ctx, address, opts...) //nolint:staticcheck // Only the deprecated version allows this call to be blocking } -func dialer(ctx context.Context, addr string) (net.Conn, error) { +func Dialer(ctx context.Context, addr string) (net.Conn, error) { var d net.Dialer if strings.HasPrefix(addr, "http://") { return d.DialContext(ctx, "tcp", strings.TrimPrefix(addr, "http://")) diff --git a/pkg/control/v2/client/dial_windows.go b/pkg/control/v2/client/dial_windows.go index 0ab339e1fdc..e8cef5bd498 100644 --- a/pkg/control/v2/client/dial_windows.go +++ b/pkg/control/v2/client/dial_windows.go @@ -20,13 +20,13 @@ import ( func dialContext(ctx context.Context, address string, maxMsgSize int, opts ...grpc.DialOption) (*grpc.ClientConn, error) { opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithContextDialer(dialer), + grpc.WithContextDialer(Dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)), ) return grpc.DialContext(ctx, address, opts...) //nolint:staticcheck // Only the deprecated version allows this call to be blocking } -func dialer(ctx context.Context, addr string) (net.Conn, error) { +func Dialer(ctx context.Context, addr string) (net.Conn, error) { if strings.HasPrefix(addr, "http://") { var d net.Dialer return d.DialContext(ctx, "tcp", strings.TrimPrefix(addr, "http://"))