Skip to content

Commit 0c369a3

Browse files
authored
Merge branch '8.19' into mergify/bp/8.19/pr-8605
2 parents 567a93e + c799ef4 commit 0c369a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2939
-420
lines changed

.buildkite/bk.integration-fips.pipeline.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ steps:
3636
- integration-fips-cloud-image
3737
env:
3838
ASDF_TERRAFORM_VERSION: 1.9.2
39-
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
40-
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
4139
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
4240
command: |
4341
source .buildkite/scripts/steps/ess_start.sh
@@ -58,8 +56,6 @@ steps:
5856
- packaging-ubuntu-x86-64-fips # Reuse artifacts produced in .buildkite/integration.pipeline.yml
5957
env:
6058
FIPS: "true"
61-
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
62-
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
6359
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
6460
TEST_PACKAGE: "github.com/elastic/elastic-agent/testing/integration/ess"
6561
command: |
@@ -88,8 +84,6 @@ steps:
8884
- packaging-ubuntu-arm64-fips
8985
env:
9086
FIPS: "true"
91-
CUSTOM_IMAGE_TAG: "git-${BUILDKITE_COMMIT:0:12}"
92-
CI_ELASTIC_AGENT_DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
9387
TF_VAR_integration_server_docker_image: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips:git-${BUILDKITE_COMMIT:0:12}"
9488
TEST_PACKAGE: "github.com/elastic/elastic-agent/testing/integration/ess"
9589
command: |

NOTICE-fips.txt

Lines changed: 252 additions & 10 deletions
Large diffs are not rendered by default.

NOTICE.txt

Lines changed: 254 additions & 12 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/docker/docker v28.1.1+incompatible
1515
github.com/docker/go-units v0.5.0
1616
github.com/dolmen-go/contextio v0.0.0-20200217195037-68fc5150bcd5
17-
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250624070124-8e1732a1b199
17+
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250625233418-1eec383034c2
1818
github.com/elastic/cloud-on-k8s/v2 v2.0.0-20250327073047-b624240832ae
1919
github.com/elastic/elastic-agent-autodiscover v0.9.2
2020
github.com/elastic/elastic-agent-client/v7 v7.17.2
@@ -51,6 +51,7 @@ require (
5151
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter v0.127.0
5252
github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.127.0
5353
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.127.0
54+
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension v0.127.0
5455
github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/k8sobserver v0.127.0
5556
github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.127.0
5657
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status v0.127.0
@@ -82,14 +83,14 @@ require (
8283
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.127.0
8384
go.opentelemetry.io/collector/receiver/nopreceiver v0.127.0
8485
go.uber.org/zap v1.27.0
85-
golang.org/x/crypto v0.38.0
86+
golang.org/x/crypto v0.39.0
8687
golang.org/x/exp v0.0.0-20250215185904-eff6e970281f
87-
golang.org/x/mod v0.24.0
88+
golang.org/x/mod v0.25.0
8889
golang.org/x/net v0.40.0
89-
golang.org/x/sync v0.14.0
90+
golang.org/x/sync v0.15.0
9091
golang.org/x/sys v0.33.0
9192
golang.org/x/term v0.32.0
92-
golang.org/x/text v0.25.0
93+
golang.org/x/text v0.26.0
9394
golang.org/x/time v0.11.0
9495
golang.org/x/tools v0.33.0
9596
google.golang.org/grpc v1.72.1
@@ -482,7 +483,7 @@ require (
482483
github.com/mdlayher/socket v0.4.1 // indirect
483484
github.com/mdlayher/vsock v1.2.1 // indirect
484485
github.com/meraki/dashboard-api-go/v3 v3.0.9 // indirect
485-
github.com/microsoft/go-mssqldb v1.7.2 // indirect
486+
github.com/microsoft/go-mssqldb v1.8.2 // indirect
486487
github.com/microsoft/wmi v0.25.1 // indirect
487488
github.com/miekg/dns v1.1.63 // indirect
488489
github.com/mileusna/useragent v1.3.4 // indirect
@@ -592,6 +593,7 @@ require (
592593
github.com/tilinna/clock v1.1.0 // indirect
593594
github.com/tklauser/go-sysconf v0.3.12 // indirect
594595
github.com/tklauser/numcpus v0.8.0 // indirect
596+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
595597
github.com/twmb/murmur3 v1.1.8 // indirect
596598
github.com/ua-parser/uap-go v0.0.0-20250213224047-9c035f085b90 // indirect
597599
github.com/ugorji/go/codec v1.2.7 // indirect
@@ -754,5 +756,5 @@ replace (
754756
github.com/fsnotify/fsnotify => github.com/elastic/fsnotify v1.6.1-0.20240920222514-49f82bdbc9e3
755757
github.com/google/gopacket => github.com/elastic/gopacket v1.1.20-0.20241002174017-e8c5fda595e6
756758
github.com/insomniacslk/dhcp => github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3 // indirect
757-
github.com/meraki/dashboard-api-go/v3 => github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250514220331-e52c94766b6f
759+
github.com/meraki/dashboard-api-go/v3 => github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250616163611-a325b49669a4
758760
)

go.sum

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ github.com/elastic/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumpti
514514
github.com/elastic/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption v1.1.0-elastic/go.mod h1:0vCBR1wgGwZeGmloJ+eCWIZF2S47grTXRzj2mftg2Nk=
515515
github.com/elastic/bayeux v1.0.5 h1:UceFq01ipmT3S8DzFK+uVAkbCdiPR0Bqei8qIGmUeY0=
516516
github.com/elastic/bayeux v1.0.5/go.mod h1:CSI4iP7qeo5MMlkznGvYKftp8M7qqP/3nzmVZoXHY68=
517-
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250624070124-8e1732a1b199 h1:JGBhzeOwTpfv1rzmYtEv6PS1GVIxvkOOPe7t66yepDA=
518-
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250624070124-8e1732a1b199/go.mod h1:flDsqeDiwyGd0Vev3rmoHupoc5AUuBTvZiuL/K7Y8+I=
517+
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250625233418-1eec383034c2 h1:m9B6lV2ee2vtSywja6OxS8RhH6SiBO98+uXB+2onc4o=
518+
github.com/elastic/beats/v7 v7.0.0-alpha2.0.20250625233418-1eec383034c2/go.mod h1:ylcsTlfTKkLBm7HohfB4GKWXePe8uRMhDZHyQxcEPeY=
519519
github.com/elastic/cloud-on-k8s/v2 v2.0.0-20250327073047-b624240832ae h1:OiShmbWAyGU0MS0ADJWr1/QgeLIZliMk9xsrFicR3/s=
520520
github.com/elastic/cloud-on-k8s/v2 v2.0.0-20250327073047-b624240832ae/go.mod h1:D2IckZVXARugvikE4fv1glvaJMohKSZRzrPsxCjo9O0=
521521
github.com/elastic/elastic-agent-autodiscover v0.9.2 h1:eBmru2v66HRRHOFf89rDl9OZUr7VsPoT4+ZNYHW6e9I=
@@ -1143,8 +1143,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U
11431143
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
11441144
github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ=
11451145
github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE=
1146-
github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA=
1147-
github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA=
1146+
github.com/microsoft/go-mssqldb v1.8.2 h1:236sewazvC8FvG6Dr3bszrVhMkAl4KYImryLkRMCd0I=
1147+
github.com/microsoft/go-mssqldb v1.8.2/go.mod h1:vp38dT33FGfVotRiTmDo3bFyaHq+p3LektQrjTULowo=
11481148
github.com/microsoft/wmi v0.25.1 h1:sQv9hCEHtW5K6yEVL78T6XGRMGxk4aTpcJwCiB5rLN0=
11491149
github.com/microsoft/wmi v0.25.1/go.mod h1:1zbdSF0A+5OwTUII5p3hN7/K6KF2m3o27pSG6Y51VU8=
11501150
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
@@ -1279,6 +1279,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/otl
12791279
github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/otlpencodingextension v0.127.0/go.mod h1:PuBIKJHNhHfyrBojM0q9OJDoUB2pA7cb2ytVYd3jLvA=
12801280
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.127.0 h1:jZ1jm12S1KZ28lI9mqWbqnAnTVVBoBOcDGTmgrTQJ08=
12811281
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.127.0/go.mod h1:muh17dM7w489SrmFc6n42wWA+wWvTLV1BlE92xUY150=
1282+
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension v0.127.0 h1:YMWd06HhyJY6iTlwfENNMEXNIyVtQ6A2mZ9TUt/Wje4=
1283+
github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension v0.127.0/go.mod h1:PaDEiW3h30o0LQlemkTaKbPac6RzxnDthw/ZKQQkbLE=
12821284
github.com/open-telemetry/opentelemetry-collector-contrib/extension/k8sleaderelector v0.127.0 h1:FVzar7k+uGx7hrLUqwfKhCyrfQFCWLqRUNR/W5zUsoc=
12831285
github.com/open-telemetry/opentelemetry-collector-contrib/extension/k8sleaderelector v0.127.0/go.mod h1:N1aky/3s9tGQkSVII5BoemeEp6rCsFLjxg7pmDhOSV0=
12841286
github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer v0.127.0 h1:IxhkClhCt4W/KhyRru1vIzOVmVzRpwRsGh6D+vLgP+0=
@@ -1606,8 +1608,10 @@ github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0h
16061608
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
16071609
github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY=
16081610
github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE=
1609-
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250514220331-e52c94766b6f h1:YasKUxSiuObaGcyQ9y4D4w3Y0GbTpStdZjYOexUlyV8=
1610-
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250514220331-e52c94766b6f/go.mod h1:COGDRzuD05ZS/zp0lDCTDFhx6kAuuNdhDjY0y2ifi5o=
1611+
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250616163611-a325b49669a4 h1:9FaZ9LJ/bYBf0HV9UKZ9uhD2Jnt10zj10r0Bjo7a/Wc=
1612+
github.com/tommyers-elastic/dashboard-api-go/v3 v3.0.0-20250616163611-a325b49669a4/go.mod h1:COGDRzuD05ZS/zp0lDCTDFhx6kAuuNdhDjY0y2ifi5o=
1613+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
1614+
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
16111615
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b h1:X/8hkb4rQq3+QuOxpJK7gWmAXmZucF0EI1s1BfBLq6U=
16121616
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b/go.mod h1:jAqhj/JBVC1PwcLTWd6rjQyGyItxxrhpiBl8LSuAGmw=
16131617
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
@@ -1967,8 +1971,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf
19671971
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
19681972
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
19691973
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
1970-
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
1971-
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
1974+
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
1975+
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
19721976
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
19731977
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
19741978
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -2007,8 +2011,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
20072011
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
20082012
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
20092013
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
2010-
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
2011-
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
2014+
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
2015+
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
20122016
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
20132017
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
20142018
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -2078,8 +2082,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
20782082
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
20792083
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
20802084
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
2081-
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
2082-
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
2085+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
2086+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
20832087
golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
20842088
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
20852089
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -2181,8 +2185,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
21812185
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
21822186
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
21832187
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
2184-
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
2185-
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
2188+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
2189+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
21862190
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
21872191
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
21882192
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

internal/pkg/agent/application/application.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ func New(
224224
return nil, nil, nil, errors.New(err, "failed to initialize composable controller")
225225
}
226226

227-
otelManager := otelmanager.NewOTelManager(log.Named("otel_manager"))
227+
otelManager, err := otelmanager.NewOTelManager(log.Named("otel_manager"), logLevel, baseLogger, otelmanager.EmbeddedExecutionMode)
228+
if err != nil {
229+
return nil, nil, nil, fmt.Errorf("failed to create otel manager: %w", err)
230+
}
228231
coord := coordinator.New(log, cfg, logLevel, agentInfo, specs, reexec, upgrader, runtime, configMgr, varsManager, caps, monitor, isManaged, otelManager, actionAcker, compModifiers...)
229232
if managed != nil {
230233
// the coordinator requires the config manager as well as in managed-mode the config manager requires the

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ func createCoordinator(t testing.TB, ctx context.Context, opts ...CoordinatorOpt
10781078
cfg.Port = 0
10791079
rm, err := runtime.NewManager(l, l, ai, apmtest.DiscardTracer, monitoringMgr, cfg)
10801080
require.NoError(t, err)
1081-
otelMgr := otelmanager.NewOTelManager(l)
1081+
otelMgr, err := otelmanager.NewOTelManager(l, logp.InfoLevel, l, otelmanager.EmbeddedExecutionMode)
1082+
require.NoError(t, err)
10821083

10831084
caps, err := capabilities.LoadFile(paths.AgentCapabilitiesPath(), l)
10841085
require.NoError(t, err)

internal/pkg/agent/cmd/otel.go

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ package cmd
66

77
import (
88
"context"
9+
"fmt"
910
"os"
1011

12+
"go.uber.org/zap"
13+
"go.uber.org/zap/zapcore"
14+
1115
"github.com/spf13/cobra"
1216
"github.com/spf13/pflag"
17+
"go.opentelemetry.io/collector/otelcol"
1318

19+
"github.com/elastic/elastic-agent-libs/logp"
1420
"github.com/elastic/elastic-agent-libs/service"
21+
1522
"github.com/elastic/elastic-agent/internal/pkg/cli"
1623
"github.com/elastic/elastic-agent/internal/pkg/otel"
24+
"github.com/elastic/elastic-agent/internal/pkg/otel/agentprovider"
25+
"github.com/elastic/elastic-agent/internal/pkg/otel/manager"
26+
"github.com/elastic/elastic-agent/internal/pkg/release"
27+
"github.com/elastic/elastic-agent/pkg/core/logger"
1728
)
1829

1930
func newOtelCommandWithArgs(args []string, streams *cli.IOStreams) *cobra.Command {
@@ -26,10 +37,18 @@ func newOtelCommandWithArgs(args []string, streams *cli.IOStreams) *cobra.Comman
2637
if err != nil {
2738
return err
2839
}
40+
supervised, err := cmd.Flags().GetBool(manager.OtelSetSupervisedFlagName)
41+
if err != nil {
42+
return err
43+
}
44+
supervisedLoggingLevel, err := cmd.Flags().GetString(manager.OtelSupervisedLoggingLevelFlagName)
45+
if err != nil {
46+
return err
47+
}
2948
if err := prepareEnv(); err != nil {
3049
return err
3150
}
32-
return runCollector(cmd.Context(), cfgFiles)
51+
return RunCollector(cmd.Context(), cfgFiles, supervised, supervisedLoggingLevel)
3352
},
3453
PreRun: func(c *cobra.Command, args []string) {
3554
// hide inherited flags not to bloat help with flags not related to otel
@@ -57,7 +76,11 @@ func hideInheritedFlags(c *cobra.Command) {
5776
})
5877
}
5978

60-
func runCollector(cmdCtx context.Context, configFiles []string) error {
79+
func RunCollector(cmdCtx context.Context, configFiles []string, supervised bool, supervisedLoggingLevel string) error {
80+
settings, err := prepareCollectorSettings(configFiles, supervised, supervisedLoggingLevel)
81+
if err != nil {
82+
return fmt.Errorf("failed to prepare collector settings: %w", err)
83+
}
6184
// Windows: Mark service as stopped.
6285
// After this is run, the service is considered by the OS to be stopped.
6386
// This must be the first deferred cleanup task (last to execute).
@@ -79,7 +102,58 @@ func runCollector(cmdCtx context.Context, configFiles []string) error {
79102
defer cancel()
80103
go service.ProcessWindowsControlEvents(stopCollector)
81104

82-
return otel.Run(ctx, stop, configFiles)
105+
return otel.Run(ctx, stop, settings)
106+
}
107+
108+
func prepareCollectorSettings(configFiles []string, supervised bool, supervisedLoggingLevel string) (*otelcol.CollectorSettings, error) {
109+
var settings *otelcol.CollectorSettings
110+
if supervised {
111+
// add stdin config provider
112+
configProvider, err := agentprovider.NewBufferProvider(os.Stdin)
113+
if err != nil {
114+
return nil, fmt.Errorf("failed to create config provider: %w", err)
115+
}
116+
settings = otel.NewSettings(release.Version(), []string{configProvider.URI()},
117+
otel.WithConfigProviderFactory(configProvider.NewFactory()),
118+
)
119+
120+
// setup logger
121+
defaultCfg := logger.DefaultLoggingConfig()
122+
defaultEventLogCfg := logger.DefaultEventLoggingConfig()
123+
124+
defaultCfg.ToStderr = true
125+
defaultCfg.ToFiles = false
126+
127+
defaultEventLogCfg.ToFiles = false
128+
defaultEventLogCfg.ToStderr = true
129+
130+
var logLevelSettingErr error
131+
if supervisedLoggingLevel != "" {
132+
if logLevelSettingErr = defaultCfg.Level.Unpack(supervisedLoggingLevel); logLevelSettingErr != nil {
133+
defaultCfg.Level = logp.InfoLevel
134+
}
135+
} else {
136+
defaultCfg.Level = logp.InfoLevel
137+
}
138+
139+
l, err := logger.NewFromConfig("edot", defaultCfg, defaultEventLogCfg, false)
140+
if err != nil {
141+
return nil, fmt.Errorf("failed to create logger: %w", err)
142+
}
143+
144+
if logLevelSettingErr != nil {
145+
l.Warnf("Fallback to default logging level due to: %v", logLevelSettingErr)
146+
}
147+
148+
settings.LoggingOptions = []zap.Option{zap.WrapCore(func(zapcore.Core) zapcore.Core {
149+
return l.Core()
150+
})}
151+
152+
settings.DisableGracefulShutdown = false
153+
} else {
154+
settings = otel.NewSettings(release.Version(), configFiles)
155+
}
156+
return settings, nil
83157
}
84158

85159
func prepareEnv() error {

internal/pkg/agent/cmd/otel_flags.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"go.opentelemetry.io/collector/featuregate"
1515

1616
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
17+
"github.com/elastic/elastic-agent/internal/pkg/otel/manager"
1718
)
1819

1920
const (
@@ -28,6 +29,16 @@ func setupOtelFlags(flags *pflag.FlagSet) {
2829
flags.StringArray(otelSetFlagName, []string{}, "Set arbitrary component config property. The component has to be defined in the config file and the flag"+
2930
" has a higher precedence. Array config properties are overridden and maps are joined. Example --set=processors.batch.timeout=2s")
3031

32+
flags.Bool(manager.OtelSetSupervisedFlagName, false, "Set that this collector is supervised.")
33+
// the only error we can get here is that the flag does not exist
34+
// but look above, so we explicitly ignore it
35+
_ = flags.MarkHidden(manager.OtelSetSupervisedFlagName)
36+
37+
flags.String(manager.OtelSupervisedLoggingLevelFlagName, "info", "Set the logging level of the supervised collector.")
38+
// the only error we can get here is that the flag does not exist
39+
// but look above, so we explicitly ignore it
40+
_ = flags.MarkHidden(manager.OtelSupervisedLoggingLevelFlagName)
41+
3142
goFlags := new(flag.FlagSet)
3243
featuregate.GlobalRegistry().RegisterFlags(goFlags)
3344

0 commit comments

Comments
 (0)