Skip to content

Commit 3a8e008

Browse files
[8.19] (backport #10240) Use a random port for otel collector monitoring endpoint (#10520)
* Use a random port for otel collector monitoring endpoint (#10240) * Use a random port for otel collector monitoring endpoint * mage notice * Use an env variable * Fix linter warnings * Fix random port determination for the embedded otel collector * Drop the ports functions from the utils package * fixup! Fix random port determination for the embedded otel collector * Ensure no port conflicts * Clean up port assignment * Verify that returned ports are unique * Add port conflict test * Fix docstring typo * More comments * Add comments explaining the port conflict test * Update internal/pkg/otel/manager/execution_subprocess.go Co-authored-by: Blake Rouse <[email protected]> --------- Co-authored-by: Blake Rouse <[email protected]> (cherry picked from commit 5cb8c31) # Conflicts: # NOTICE-fips.txt # NOTICE.txt # go.mod # internal/pkg/otel/manager/execution_embedded.go # internal/pkg/otel/manager/manager.go # internal/pkg/otel/manager/manager_test.go * Fix conflicts --------- Co-authored-by: Mikołaj Świątek <[email protected]>
1 parent 1e2032d commit 3a8e008

File tree

14 files changed

+1478
-669
lines changed

14 files changed

+1478
-669
lines changed

NOTICE-fips.txt

Lines changed: 444 additions & 270 deletions
Large diffs are not rendered by default.

NOTICE.txt

Lines changed: 444 additions & 270 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ require (
7171
github.com/rs/zerolog v1.27.0
7272
github.com/sajari/regression v1.0.1
7373
github.com/schollz/progressbar/v3 v3.13.1
74-
github.com/spf13/cobra v1.9.1
75-
github.com/spf13/pflag v1.0.6
76-
github.com/stretchr/testify v1.10.0
74+
github.com/spf13/cobra v1.10.1
75+
github.com/spf13/pflag v1.0.9
76+
github.com/stretchr/testify v1.11.1
7777
github.com/winlabs/gowin32 v0.0.0-20240930213947-f504d7e14639
7878
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0
7979
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0
@@ -85,7 +85,6 @@ require (
8585
go.opentelemetry.io/collector/pipeline v1.38.0
8686
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.132.0
8787
go.opentelemetry.io/collector/receiver/nopreceiver v0.132.0
88-
go.opentelemetry.io/collector/service v0.132.0
8988
go.uber.org/zap v1.27.0
9089
golang.org/x/crypto v0.41.0
9190
golang.org/x/exp v0.0.0-20250215185904-eff6e970281f
@@ -98,7 +97,7 @@ require (
9897
golang.org/x/time v0.12.0
9998
golang.org/x/tools v0.36.0
10099
google.golang.org/grpc v1.75.0
101-
google.golang.org/protobuf v1.36.7
100+
google.golang.org/protobuf v1.36.8
102101
gopkg.in/ini.v1 v1.67.0
103102
gopkg.in/yaml.v2 v2.4.0
104103
gopkg.in/yaml.v3 v3.0.1
@@ -565,7 +564,7 @@ require (
565564
github.com/pkg/errors v0.9.1 // indirect
566565
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
567566
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
568-
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
567+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
569568
github.com/prometheus/alertmanager v0.28.1 // indirect
570569
github.com/prometheus/client_golang v1.23.0 // indirect
571570
github.com/prometheus/client_model v0.6.2 // indirect
@@ -588,7 +587,7 @@ require (
588587
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33 // indirect
589588
github.com/segmentio/fasthash v1.0.3 // indirect
590589
github.com/sergi/go-diff v1.3.1 // indirect
591-
github.com/shirou/gopsutil/v4 v4.25.7 // indirect
590+
github.com/shirou/gopsutil/v4 v4.25.8 // indirect
592591
github.com/shopspring/decimal v1.4.0 // indirect
593592
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
594593
github.com/sirupsen/logrus v1.9.3 // indirect
@@ -686,6 +685,7 @@ require (
686685
go.opentelemetry.io/collector/scraper v0.132.0 // indirect
687686
go.opentelemetry.io/collector/scraper/scraperhelper v0.132.0 // indirect
688687
go.opentelemetry.io/collector/semconv v0.128.1-0.20250610090210-188191247685 // indirect
688+
go.opentelemetry.io/collector/service v0.132.0 // indirect
689689
go.opentelemetry.io/collector/service/hostcapabilities v0.132.0 // indirect
690690
go.opentelemetry.io/contrib/bridges/otelzap v0.12.0 // indirect
691691
go.opentelemetry.io/contrib/detectors/gcp v1.36.0 // indirect
@@ -695,7 +695,7 @@ require (
695695
go.opentelemetry.io/contrib/otelconf v0.17.0 // indirect
696696
go.opentelemetry.io/contrib/propagators/b3 v1.37.0 // indirect
697697
go.opentelemetry.io/ebpf-profiler v0.0.0-20250212075250-7bf12d3f962f // indirect
698-
go.opentelemetry.io/otel v1.37.0 // indirect
698+
go.opentelemetry.io/otel v1.38.0 // indirect
699699
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.13.0 // indirect
700700
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.13.0 // indirect
701701
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.37.0 // indirect
@@ -707,12 +707,12 @@ require (
707707
go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.13.0 // indirect
708708
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0 // indirect
709709
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.37.0 // indirect
710-
go.opentelemetry.io/otel/log v0.13.0 // indirect
711-
go.opentelemetry.io/otel/metric v1.37.0 // indirect
712-
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
710+
go.opentelemetry.io/otel/log v0.14.0 // indirect
711+
go.opentelemetry.io/otel/metric v1.38.0 // indirect
712+
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
713713
go.opentelemetry.io/otel/sdk/log v0.13.0 // indirect
714-
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
715-
go.opentelemetry.io/otel/trace v1.37.0 // indirect
714+
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
715+
go.opentelemetry.io/otel/trace v1.38.0 // indirect
716716
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
717717
go.uber.org/atomic v1.11.0 // indirect
718718
go.uber.org/goleak v1.3.0 // indirect

go.sum

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,8 +1372,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
13721372
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13731373
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
13741374
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
1375-
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI=
1376-
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
1375+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
1376+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
13771377
github.com/poy/eachers v0.0.0-20181020210610-23942921fe77 h1:SNdqPRvRsVmYR0gKqFvrUKhFizPJ6yDiGQ++VAJIoDg=
13781378
github.com/poy/eachers v0.0.0-20181020210610-23942921fe77/go.mod h1:x1vqpbcMW9T/KRcQ4b48diSiSVtYgvwQ5xzDByEg4WE=
13791379
github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY=
@@ -1452,8 +1452,8 @@ github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KR
14521452
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
14531453
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
14541454
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
1455-
github.com/shirou/gopsutil/v4 v4.25.7 h1:bNb2JuqKuAu3tRlPv5piSmBZyMfecwQ+t/ILq+1JqVM=
1456-
github.com/shirou/gopsutil/v4 v4.25.7/go.mod h1:XV/egmwJtd3ZQjBpJVY5kndsiOO4IRqy9TQnmm6VP7U=
1455+
github.com/shirou/gopsutil/v4 v4.25.8 h1:NnAsw9lN7587WHxjJA9ryDnqhJpFH6A+wagYWTOH970=
1456+
github.com/shirou/gopsutil/v4 v4.25.8/go.mod h1:q9QdMmfAOVIw7a+eF86P7ISEU6ka+NLgkUxlopV4RwI=
14571457
github.com/shoenig/test v1.7.1 h1:UJcjSAI3aUKx52kfcfhblgyhZceouhvvs3OYdWgn+PY=
14581458
github.com/shoenig/test v1.7.1/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
14591459
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
@@ -1473,11 +1473,11 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1
14731473
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
14741474
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
14751475
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
1476-
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
1477-
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
1476+
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
1477+
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
14781478
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
1479-
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
1480-
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
1479+
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
1480+
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
14811481
github.com/spiffe/go-spiffe/v2 v2.5.0 h1:N2I01KCUkv1FAjZXJMwh95KK1ZIQLYbPfhaxw8WS0hE=
14821482
github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g=
14831483
github.com/stackitcloud/stackit-sdk-go/core v0.17.2 h1:jPyn+i8rkp2hM80+hOg0B/1EVRbMt778Tr5RWyK1m2E=
@@ -1504,8 +1504,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
15041504
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
15051505
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
15061506
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1507-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
1508-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1507+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
1508+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
15091509
github.com/testcontainers/testcontainers-go v0.38.0 h1:d7uEapLcv2P8AvH8ahLqDMMxda2W9gQN1nRbHS28HBw=
15101510
github.com/testcontainers/testcontainers-go v0.38.0/go.mod h1:C52c9MoHpWO+C4aqmgSU+hxlR5jlEayWtgYrb8Pzz1w=
15111511
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
@@ -1819,8 +1819,8 @@ go.opentelemetry.io/contrib/zpages v0.62.0 h1:9fUYTLmrK0x/lweM2uM+BOx069jLx8PxVq
18191819
go.opentelemetry.io/contrib/zpages v0.62.0/go.mod h1:C8kXoiC1Ytvereztus2R+kqdSa6W/MZ8FfS8Zwj+LiM=
18201820
go.opentelemetry.io/ebpf-profiler v0.0.0-20250212075250-7bf12d3f962f h1:DqRQ7JaRjf3TwWwfwHIvsBB/aLUs+kgrX+MrAIllALI=
18211821
go.opentelemetry.io/ebpf-profiler v0.0.0-20250212075250-7bf12d3f962f/go.mod h1:hfAVBjRN6FZjSgZUBsNzvRDJWlS46R5Y0SGVr4Jl86s=
1822-
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
1823-
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
1822+
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
1823+
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
18241824
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.13.0 h1:z6lNIajgEBVtQZHjfw2hAccPEBDs+nx58VemmXWa2ec=
18251825
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.13.0/go.mod h1:+kyc3bRx/Qkq05P6OCu3mTEIOxYRYzoIg+JsUp5X+PM=
18261826
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.13.0 h1:zUfYw8cscHHLwaY8Xz3fiJu+R59xBnkgq2Zr1lwmK/0=
@@ -1843,22 +1843,22 @@ go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0 h1:6VjV6Et+1Hd2iL
18431843
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0/go.mod h1:u8hcp8ji5gaM/RfcOo8z9NMnf1pVLfVY7lBY2VOGuUU=
18441844
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.37.0 h1:SNhVp/9q4Go/XHBkQ1/d5u9P/U+L1yaGPoi0x+mStaI=
18451845
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.37.0/go.mod h1:tx8OOlGH6R4kLV67YaYO44GFXloEjGPZuMjEkaaqIp4=
1846-
go.opentelemetry.io/otel/log v0.13.0 h1:yoxRoIZcohB6Xf0lNv9QIyCzQvrtGZklVbdCoyb7dls=
1847-
go.opentelemetry.io/otel/log v0.13.0/go.mod h1:INKfG4k1O9CL25BaM1qLe0zIedOpvlS5Z7XgSbmN83E=
1846+
go.opentelemetry.io/otel/log v0.14.0 h1:2rzJ+pOAZ8qmZ3DDHg73NEKzSZkhkGIua9gXtxNGgrM=
1847+
go.opentelemetry.io/otel/log v0.14.0/go.mod h1:5jRG92fEAgx0SU/vFPxmJvhIuDU9E1SUnEQrMlJpOno=
18481848
go.opentelemetry.io/otel/log/logtest v0.13.0 h1:xxaIcgoEEtnwdgj6D6Uo9K/Dynz9jqIxSDu2YObJ69Q=
18491849
go.opentelemetry.io/otel/log/logtest v0.13.0/go.mod h1:+OrkmsAH38b+ygyag1tLjSFMYiES5UHggzrtY1IIEA8=
1850-
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
1851-
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
1852-
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
1853-
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
1850+
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
1851+
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
1852+
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
1853+
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
18541854
go.opentelemetry.io/otel/sdk/log v0.13.0 h1:I3CGUszjM926OphK8ZdzF+kLqFvfRY/IIoFq/TjwfaQ=
18551855
go.opentelemetry.io/otel/sdk/log v0.13.0/go.mod h1:lOrQyCCXmpZdN7NchXb6DOZZa1N5G1R2tm5GMMTpDBw=
18561856
go.opentelemetry.io/otel/sdk/log/logtest v0.13.0 h1:9yio6AFZ3QD9j9oqshV1Ibm9gPLlHNxurno5BreMtIA=
18571857
go.opentelemetry.io/otel/sdk/log/logtest v0.13.0/go.mod h1:QOGiAJHl+fob8Nu85ifXfuQYmJTFAvcrxL6w5/tu168=
1858-
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
1859-
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
1860-
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
1861-
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
1858+
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
1859+
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
1860+
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
1861+
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
18621862
go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os=
18631863
go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCgCSHGj4efDDo=
18641864
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
@@ -2115,8 +2115,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
21152115
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
21162116
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
21172117
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
2118-
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
2119-
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
2118+
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
2119+
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
21202120
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
21212121
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
21222122
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/pkg/agent/application/application.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ func New(
131131
if err != nil {
132132
return nil, nil, nil, fmt.Errorf("failed to create upgrader: %w", err)
133133
}
134-
monitor := componentmonitoring.New(isMonitoringSupported, cfg.Settings.DownloadConfig.OS(), cfg.Settings.MonitoringConfig, rawConfig.OTel, agentInfo, isOtelExecModeSubprocess)
134+
monitor := componentmonitoring.New(
135+
isMonitoringSupported,
136+
cfg.Settings.DownloadConfig.OS(),
137+
cfg.Settings.MonitoringConfig,
138+
agentInfo,
139+
isOtelExecModeSubprocess,
140+
)
135141

136142
runtime, err := runtime.NewManager(
137143
log,
@@ -243,7 +249,16 @@ func New(
243249
return nil, nil, nil, errors.New(err, "failed to initialize composable controller")
244250
}
245251

246-
otelManager, err := otelmanager.NewOTelManager(log.Named("otel_manager"), logLevel, baseLogger, otelExecMode, agentInfo, monitor.ComponentMonitoringConfig, cfg.Settings.ProcessConfig.StopTimeout)
252+
otelManager, err := otelmanager.NewOTelManager(
253+
log.Named("otel_manager"),
254+
logLevel, baseLogger,
255+
otelExecMode,
256+
agentInfo,
257+
0, // TODO: make this configurable in a follow-up
258+
0, // TODO: make this configurable in a follow-up
259+
monitor.ComponentMonitoringConfig,
260+
cfg.Settings.ProcessConfig.StopTimeout,
261+
)
247262
if err != nil {
248263
return nil, nil, nil, fmt.Errorf("failed to create otel manager: %w", err)
249264
}

internal/pkg/agent/application/monitoring/component/v1_monitor.go

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ import (
2121
"time"
2222
"unicode"
2323

24-
"go.opentelemetry.io/collector/confmap"
25-
"go.opentelemetry.io/collector/service"
24+
koanfmaps "github.com/knadh/koanf/maps"
2625

2726
"github.com/elastic/elastic-agent/pkg/component"
2827
"github.com/elastic/elastic-agent/pkg/utils"
2928

30-
koanfmaps "github.com/knadh/koanf/maps"
31-
3229
"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
3330
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
3431
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
@@ -38,6 +35,12 @@ import (
3835
)
3936

4037
const (
38+
// OtelCollectorMetricsPortEnvVarName is the name of the environment variable used to pass the collector metrics
39+
// port to the managed EDOT collector. It exists because by default we use a random port for this, and we want to
40+
// determine it as late as possible. However, the monitoring manager is instantiated early in the application
41+
// startup process, so instead we rely on this variable. The OTel manager is required to set it whenever it starts
42+
// a collector.
43+
OtelCollectorMetricsPortEnvVarName = "EDOT_COLLECTOR_METRICS_PORT"
4144
// args: data path, pipeline name, application name
4245
logFileFormat = "%s/logs/%s"
4346
// args: data path, install path, pipeline name, application name
@@ -93,7 +96,6 @@ var (
9396
type BeatsMonitor struct {
9497
enabled bool // feature flag disabling whole v1 monitoring story
9598
config *monitoringConfig
96-
otelConfig *confmap.Conf
9799
operatingSystem string
98100
agentInfo info.Agent
99101
isOtelRuntimeSubprocess bool
@@ -115,13 +117,12 @@ type monitoringConfig struct {
115117
}
116118

117119
// New creates a new BeatsMonitor instance.
118-
func New(enabled bool, operatingSystem string, cfg *monitoringCfg.MonitoringConfig, otelCfg *confmap.Conf, agentInfo info.Agent, isOtelRuntimeSubprocess bool) *BeatsMonitor {
120+
func New(enabled bool, operatingSystem string, cfg *monitoringCfg.MonitoringConfig, agentInfo info.Agent, isOtelRuntimeSubprocess bool) *BeatsMonitor {
119121
return &BeatsMonitor{
120122
enabled: enabled,
121123
config: &monitoringConfig{
122124
C: cfg,
123125
},
124-
otelConfig: otelCfg,
125126
operatingSystem: operatingSystem,
126127
agentInfo: agentInfo,
127128
isOtelRuntimeSubprocess: isOtelRuntimeSubprocess,
@@ -149,7 +150,6 @@ func (b *BeatsMonitor) Reload(rawConfig *config.Config) error {
149150
}
150151

151152
b.config = &newConfig
152-
b.otelConfig = rawConfig.OTel
153153
return nil
154154
}
155155

@@ -519,34 +519,9 @@ func (b *BeatsMonitor) monitoringNamespace() string {
519519
}
520520

521521
func (b *BeatsMonitor) getCollectorTelemetryEndpoint() string {
522-
if b.otelConfig != nil {
523-
if serviceConfig, err := b.otelConfig.Sub("service"); err == nil {
524-
var service service.Config
525-
if serviceConfig.Unmarshal(&service, confmap.WithIgnoreUnused()) == nil {
526-
for _, reader := range service.Telemetry.Metrics.Readers {
527-
if reader.Pull == nil || reader.Pull.Exporter.Prometheus == nil {
528-
continue
529-
}
530-
prometheus := *reader.Pull.Exporter.Prometheus
531-
host := "localhost"
532-
port := 8888
533-
534-
if prometheus.Host != nil {
535-
host = *prometheus.Host
536-
}
537-
if prometheus.Port != nil {
538-
port = *prometheus.Port
539-
}
540-
if prometheus.Host != nil || prometheus.Port != nil {
541-
return host + ":" + strconv.Itoa(port)
542-
}
543-
}
544-
}
545-
}
546-
}
547-
548-
// If there is no explicit configuration, the collector publishes its telemetry on port 8888.
549-
return "localhost:8888"
522+
// The OTel manager is required to set the environment variable. See comment at the constant definition for more
523+
// information.
524+
return fmt.Sprintf("localhost:${env:%s}", OtelCollectorMetricsPortEnvVarName)
550525
}
551526

552527
// injectMetricsInput injects monitoring config for agent monitoring to the `cfg` object.

internal/pkg/agent/application/monitoring/component/v1_monitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ func TestMonitorReload(t *testing.T) {
11021102
monitorcfg.MonitorLogs = false
11031103
monitorcfg.MonitorMetrics = false
11041104

1105-
beatsMonitor := New(true, "", monitorcfg, nil, nil, false)
1105+
beatsMonitor := New(true, "", monitorcfg, nil, false)
11061106
assert.Equal(t, beatsMonitor.config.C.MonitorLogs, false)
11071107
assert.Equal(t, beatsMonitor.config.C.MonitorLogs, false)
11081108

internal/pkg/agent/cmd/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func getMonitoringFn(ctx context.Context, logger *logger.Logger, cfg map[string]
420420
}
421421
otelExecMode := otelconfig.GetExecutionModeFromConfig(logger, config)
422422
isOtelExecModeSubprocess := otelExecMode == manager.SubprocessExecutionMode
423-
monitor := componentmonitoring.New(agentCfg.Settings.V1MonitoringEnabled, agentCfg.Settings.DownloadConfig.OS(), agentCfg.Settings.MonitoringConfig, otelCfg, agentInfo, isOtelExecModeSubprocess)
423+
monitor := componentmonitoring.New(agentCfg.Settings.V1MonitoringEnabled, agentCfg.Settings.DownloadConfig.OS(), agentCfg.Settings.MonitoringConfig, agentInfo, isOtelExecModeSubprocess)
424424
return monitor.MonitoringConfig, nil
425425
}
426426

0 commit comments

Comments
 (0)