diff --git a/.chloggen/process-scraper-context.yaml b/.chloggen/process-scraper-context.yaml new file mode 100644 index 000000000000..c86605e52bae --- /dev/null +++ b/.chloggen/process-scraper-context.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: receiver/hostmetricsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Make sure the process scraper uses the gopsutil context, respecting the `root_path` configuration. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [24777] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: "This regression was introduced by #24777" + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/receiver/hostmetricsreceiver/go.mod b/receiver/hostmetricsreceiver/go.mod index 7fa24b6cbd76..5b50dc7cb870 100644 --- a/receiver/hostmetricsreceiver/go.mod +++ b/receiver/hostmetricsreceiver/go.mod @@ -5,7 +5,9 @@ go 1.20 require ( github.com/google/go-cmp v0.5.9 github.com/leoluk/perflib_exporter v0.2.1 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.85.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.85.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.85.0 github.com/shirou/gopsutil/v3 v3.23.8 github.com/stretchr/testify v1.8.4 github.com/yusufpapurcu/wmi v1.2.3 @@ -23,10 +25,19 @@ require ( require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containerd/containerd v1.7.3 // indirect + github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.6+incompatible // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logr/logr v1.2.4 // indirect @@ -39,15 +50,26 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.17.0 // indirect github.com/knadh/koanf v1.5.0 // indirect github.com/knadh/koanf/v2 v2.0.1 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/patternmatcher v0.5.0 // indirect + github.com/moby/sys/sequential v0.5.0 // indirect + github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/morikuni/aec v1.0.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.85.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc4 // indirect + github.com/opencontainers/runc v1.1.5 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_golang v1.16.0 // indirect @@ -56,9 +78,11 @@ require ( github.com/prometheus/procfs v0.10.1 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/cobra v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect + github.com/testcontainers/testcontainers-go v0.23.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect go.opencensus.io v0.24.0 // indirect @@ -87,8 +111,11 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.41.0 // indirect go.opentelemetry.io/otel/trace v1.18.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect + golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.15.0 // indirect golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.13.0 // indirect gonum.org/v1/gonum v0.14.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/receiver/hostmetricsreceiver/go.sum b/receiver/hostmetricsreceiver/go.sum index ad86d92bc9d9..9941c6f36c57 100644 --- a/receiver/hostmetricsreceiver/go.sum +++ b/receiver/hostmetricsreceiver/go.sum @@ -32,9 +32,17 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -68,18 +76,38 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= +github.com/containerd/containerd v1.7.3 h1:cKwYKkP1eTj54bP3wCdXXBymmKRQMrWjkLSWZZJDa8o= +github.com/containerd/containerd v1.7.3/go.mod h1:32FOM4/O0RkNg7AjQj3hDzN9cUGtu+HMvaKUNiqCZB8= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= +github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= +github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.6+incompatible h1:hceabKCtUgDqPu+qm0NgsaXf28Ljf4/pWFL7xjWWDgE= +github.com/docker/docker v24.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -89,6 +117,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -116,6 +145,7 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -241,6 +271,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/knadh/koanf v1.5.0 h1:q2TSd/3Pyc/5yP9ldIrSdIz26MCcyNQzW0pEAugLPNs= github.com/knadh/koanf v1.5.0/go.mod h1:Hgyjp4y8v44hpZtPzs7JZfRAW5AhN7KfZcwv1RYggDs= github.com/knadh/koanf/v2 v2.0.1 h1:1dYGITt1I23x8cfx8ZnldtezdyaZtfAuRtIFOiRzK7g= @@ -250,6 +282,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -258,6 +291,8 @@ github.com/leoluk/perflib_exporter v0.2.1 h1:/3/ut1k/jFt5p4ypjLZKDHDqlXAK6ERZPVW github.com/leoluk/perflib_exporter v0.2.1/go.mod h1:MinSWm88jguXFFrGsP56PtleUb4Qtm4tNRH/wXNXRTI= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -288,6 +323,13 @@ github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1 github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= +github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= +github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= +github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -295,16 +337,28 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= +github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= +github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= +github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -351,20 +405,26 @@ github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8d github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE= github.com/shirou/gopsutil/v3 v3.23.8/go.mod h1:7hmCaBn+2ZwaZOr6jmPBZDfawwMGuo1id3C6aM8EDqQ= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -386,10 +446,16 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= +github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= +github.com/testcontainers/testcontainers-go v0.23.0 h1:ERYTSikX01QczBLPZpqsETTBO7lInqEP349phDOVJVs= +github.com/testcontainers/testcontainers-go v0.23.0/go.mod h1:3gzuZfb7T9qfcH2pHpV4RLlWrPjeWNQah6XlYQ32c4I= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= +github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -501,6 +567,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 h1:FqrVOBQxQ8r/UwwXibI0KMolVhvFiGobSfdE33deHJM= +golang.org/x/exp v0.0.0-20230711023510-fffb14384f22/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -523,6 +590,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -554,6 +623,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= @@ -581,6 +651,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -595,6 +666,7 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -604,6 +676,7 @@ golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -635,10 +708,15 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= @@ -659,6 +737,7 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -703,6 +782,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -799,6 +880,7 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= @@ -824,6 +906,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/receiver/hostmetricsreceiver/integration_test.go b/receiver/hostmetricsreceiver/integration_test.go new file mode 100644 index 000000000000..9bab505aaa4a --- /dev/null +++ b/receiver/hostmetricsreceiver/integration_test.go @@ -0,0 +1,120 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +//go:build integration +// +build integration + +package hostmetricsreceiver + +import ( + "os/exec" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/scraperinttest" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterset" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper" +) + +func Test_ProcessScrape(t *testing.T) { + expectedFile := filepath.Join("testdata", "e2e", "expected_process.yaml") + cmd := exec.Command("/bin/sleep", "300") + require.NoError(t, cmd.Start()) + defer func() { + require.NoError(t, cmd.Process.Kill()) + }() + + scraperinttest.NewIntegrationTest( + NewFactory(), + scraperinttest.WithCustomConfig( + func(t *testing.T, cfg component.Config, ci *scraperinttest.ContainerInfo) { + rCfg := cfg.(*Config) + rCfg.CollectionInterval = time.Second + pCfg := (&processscraper.Factory{}).CreateDefaultConfig().(*processscraper.Config) + pCfg.Include = processscraper.MatchConfig{ + Config: filterset.Config{MatchType: filterset.Regexp}, + Names: []string{"sleep"}, + } + rCfg.Scrapers = map[string]internal.Config{ + "process": pCfg, + } + }), + scraperinttest.WithExpectedFile(expectedFile), + scraperinttest.WithCompareOptions( + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreTimestamp(), + ), + ).Run(t) + +} + +func Test_ProcessScrapeWithCustomRootPath(t *testing.T) { + expectedFile := filepath.Join("testdata", "e2e", "expected_process_separate_proc.yaml") + + scraperinttest.NewIntegrationTest( + NewFactory(), + scraperinttest.WithCustomConfig( + func(t *testing.T, cfg component.Config, ci *scraperinttest.ContainerInfo) { + rCfg := cfg.(*Config) + rCfg.CollectionInterval = time.Second + pCfg := (&processscraper.Factory{}).CreateDefaultConfig().(*processscraper.Config) + pCfg.Include = processscraper.MatchConfig{ + Config: filterset.Config{MatchType: filterset.Regexp}, + Names: []string{"sleep"}, + } + rCfg.Scrapers = map[string]internal.Config{ + "process": pCfg, + } + rCfg.RootPath = filepath.Join("testdata", "e2e") + }), + scraperinttest.WithExpectedFile(expectedFile), + scraperinttest.WithCompareOptions( + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreTimestamp(), + ), + ).Run(t) + +} + +func Test_ProcessScrapeWithBadRootPathAndEnvVar(t *testing.T) { + expectedFile := filepath.Join("testdata", "e2e", "expected_process_separate_proc.yaml") + t.Setenv("HOST_PROC", filepath.Join("testdata", "e2e", "proc")) + scraperinttest.NewIntegrationTest( + NewFactory(), + scraperinttest.WithCustomConfig( + func(t *testing.T, cfg component.Config, ci *scraperinttest.ContainerInfo) { + rCfg := cfg.(*Config) + rCfg.CollectionInterval = time.Second + pCfg := (&processscraper.Factory{}).CreateDefaultConfig().(*processscraper.Config) + pCfg.Include = processscraper.MatchConfig{ + Config: filterset.Config{MatchType: filterset.Regexp}, + Names: []string{"sleep"}, + } + rCfg.Scrapers = map[string]internal.Config{ + "process": pCfg, + } + rCfg.RootPath = filepath.Join("testdata", "NOT A VALID FOLDER") + }), + scraperinttest.WithExpectedFile(expectedFile), + scraperinttest.WithCompareOptions( + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreTimestamp(), + ), + ).Run(t) + +} diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process.go index 261abcfa966c..be5231652e3e 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process.go @@ -72,25 +72,25 @@ type processHandles interface { } type processHandle interface { - Name() (string, error) - Exe() (string, error) - Username() (string, error) - Cmdline() (string, error) - CmdlineSlice() ([]string, error) - Times() (*cpu.TimesStat, error) - Percent(time.Duration) (float64, error) - MemoryInfo() (*process.MemoryInfoStat, error) - MemoryPercent() (float32, error) - IOCounters() (*process.IOCountersStat, error) - NumThreads() (int32, error) - CreateTime() (int64, error) - Parent() (*process.Process, error) - Ppid() (int32, error) - PageFaults() (*process.PageFaultsStat, error) - NumCtxSwitches() (*process.NumCtxSwitchesStat, error) - NumFDs() (int32, error) + NameWithContext(context.Context) (string, error) + ExeWithContext(context.Context) (string, error) + UsernameWithContext(context.Context) (string, error) + CmdlineWithContext(context.Context) (string, error) + CmdlineSliceWithContext(context.Context) ([]string, error) + TimesWithContext(context.Context) (*cpu.TimesStat, error) + PercentWithContext(context.Context, time.Duration) (float64, error) + MemoryInfoWithContext(context.Context) (*process.MemoryInfoStat, error) + MemoryPercentWithContext(context.Context) (float32, error) + IOCountersWithContext(context.Context) (*process.IOCountersStat, error) + NumThreadsWithContext(context.Context) (int32, error) + CreateTimeWithContext(context.Context) (int64, error) + ParentWithContext(context.Context) (*process.Process, error) + PpidWithContext(context.Context) (int32, error) + PageFaultsWithContext(context.Context) (*process.PageFaultsStat, error) + NumCtxSwitchesWithContext(context.Context) (*process.NumCtxSwitchesStat, error) + NumFDsWithContext(context.Context) (int32, error) // If gatherUsed is true, the currently used value will be gathered and added to the resulting RlimitStat. - RlimitUsage(gatherUsed bool) ([]process.RlimitStat, error) + RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]process.RlimitStat, error) } type gopsProcessHandles struct { @@ -118,11 +118,11 @@ func getProcessHandlesInternal(ctx context.Context) (processHandles, error) { return &gopsProcessHandles{handles: processes}, nil } -func parentPid(handle processHandle, pid int32) (int32, error) { +func parentPid(ctx context.Context, handle processHandle, pid int32) (int32, error) { // special case for pid 0 and pid 1 in darwin if pid == 0 || (pid == 1 && runtime.GOOS == "darwin") { return 0, nil } - return handle.Ppid() + return handle.PpidWithContext(ctx) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper.go index d115a740edf9..6edb1d90ae8a 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper.go @@ -50,7 +50,7 @@ type scraper struct { ucals map[int32]*ucal.CPUUtilizationCalculator // for mocking - getProcessCreateTime func(p processHandle) (int64, error) + getProcessCreateTime func(p processHandle, ctx context.Context) (int64, error) getProcessHandles func(context.Context) (processHandles, error) handleCountManager handlecount.Manager @@ -61,7 +61,7 @@ func newProcessScraper(settings receiver.CreateSettings, cfg *Config) (*scraper, scraper := &scraper{ settings: settings, config: cfg, - getProcessCreateTime: processHandle.CreateTime, + getProcessCreateTime: processHandle.CreateTimeWithContext, getProcessHandles: getProcessHandlesInternal, scrapeProcessDelay: cfg.ScrapeProcessDelay, ucals: make(map[int32]*ucal.CPUUtilizationCalculator), @@ -92,7 +92,7 @@ func (s *scraper) start(context.Context, component.Host) error { return nil } -func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) { +func (s *scraper) scrape(ctx context.Context) (pmetric.Metrics, error) { var errs scrapererror.ScrapeErrors data, err := s.getProcessMetadata() @@ -106,49 +106,50 @@ func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) { } presentPIDs := make(map[int32]struct{}, len(data)) + ctx = context.WithValue(ctx, common.EnvKey, s.config.EnvMap) for _, md := range data { presentPIDs[md.pid] = struct{}{} now := pcommon.NewTimestampFromTime(time.Now()) - if err = s.scrapeAndAppendCPUTimeMetric(now, md.handle, md.pid); err != nil { + if err = s.scrapeAndAppendCPUTimeMetric(ctx, now, md.handle, md.pid); err != nil { errs.AddPartial(cpuMetricsLen, fmt.Errorf("error reading cpu times for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendMemoryUsageMetrics(now, md.handle); err != nil { + if err = s.scrapeAndAppendMemoryUsageMetrics(ctx, now, md.handle); err != nil { errs.AddPartial(memoryMetricsLen, fmt.Errorf("error reading memory info for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendMemoryUtilizationMetric(now, md.handle); err != nil { + if err = s.scrapeAndAppendMemoryUtilizationMetric(ctx, now, md.handle); err != nil { errs.AddPartial(memoryUtilizationMetricsLen, fmt.Errorf("error reading memory utilization for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendDiskMetrics(now, md.handle); err != nil && !s.config.MuteProcessIOError { + if err = s.scrapeAndAppendDiskMetrics(ctx, now, md.handle); err != nil && !s.config.MuteProcessIOError { errs.AddPartial(diskMetricsLen, fmt.Errorf("error reading disk usage for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendPagingMetric(now, md.handle); err != nil { + if err = s.scrapeAndAppendPagingMetric(ctx, now, md.handle); err != nil { errs.AddPartial(pagingMetricsLen, fmt.Errorf("error reading memory paging info for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendThreadsMetrics(now, md.handle); err != nil { + if err = s.scrapeAndAppendThreadsMetrics(ctx, now, md.handle); err != nil { errs.AddPartial(threadMetricsLen, fmt.Errorf("error reading thread info for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendContextSwitchMetrics(now, md.handle); err != nil { + if err = s.scrapeAndAppendContextSwitchMetrics(ctx, now, md.handle); err != nil { errs.AddPartial(contextSwitchMetricsLen, fmt.Errorf("error reading context switch counts for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendOpenFileDescriptorsMetric(now, md.handle); err != nil { + if err = s.scrapeAndAppendOpenFileDescriptorsMetric(ctx, now, md.handle); err != nil { errs.AddPartial(fileDescriptorMetricsLen, fmt.Errorf("error reading open file descriptor count for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendHandlesMetric(now, int64(md.pid)); err != nil { + if err = s.scrapeAndAppendHandlesMetric(ctx, now, int64(md.pid)); err != nil { errs.AddPartial(handleMetricsLen, fmt.Errorf("error reading handle count for process %q (pid %v): %w", md.executable.name, md.pid, err)) } - if err = s.scrapeAndAppendSignalsPendingMetric(now, md.handle); err != nil { + if err = s.scrapeAndAppendSignalsPendingMetric(ctx, now, md.handle); err != nil { errs.AddPartial(signalMetricsLen, fmt.Errorf("error reading pending signals for process %q (pid %v): %w", md.executable.name, md.pid, err)) } @@ -188,14 +189,14 @@ func (s *scraper) getProcessMetadata() ([]*processMetadata, error) { pid := handles.Pid(i) handle := handles.At(i) - exe, err := getProcessExecutable(handle) + exe, err := getProcessExecutable(ctx, handle) if err != nil { if !s.config.MuteProcessExeError { errs.AddPartial(1, fmt.Errorf("error reading process executable for pid %v: %w", pid, err)) } } - name, err := getProcessName(handle, exe) + name, err := getProcessName(ctx, handle, exe) if err != nil { if !s.config.MuteProcessNameError { errs.AddPartial(1, fmt.Errorf("error reading process name for pid %v: %w", pid, err)) @@ -211,17 +212,17 @@ func (s *scraper) getProcessMetadata() ([]*processMetadata, error) { continue } - command, err := getProcessCommand(handle) + command, err := getProcessCommand(ctx, handle) if err != nil { errs.AddPartial(0, fmt.Errorf("error reading command for process %q (pid %v): %w", executable.name, pid, err)) } - username, err := handle.Username() + username, err := handle.UsernameWithContext(ctx) if err != nil { errs.AddPartial(0, fmt.Errorf("error reading username for process %q (pid %v): %w", executable.name, pid, err)) } - createTime, err := s.getProcessCreateTime(handle) + createTime, err := s.getProcessCreateTime(handle, ctx) if err != nil { errs.AddPartial(0, fmt.Errorf("error reading create time for process %q (pid %v): %w", executable.name, pid, err)) // set the start time to now to avoid including this when a scrape_process_delay is set @@ -231,7 +232,7 @@ func (s *scraper) getProcessMetadata() ([]*processMetadata, error) { continue } - parentPid, err := parentPid(handle, pid) + parentPid, err := parentPid(ctx, handle, pid) if err != nil { errs.AddPartial(0, fmt.Errorf("error reading parent pid for process %q (pid %v): %w", executable.name, pid, err)) } @@ -252,12 +253,12 @@ func (s *scraper) getProcessMetadata() ([]*processMetadata, error) { return data, errs.Combine() } -func (s *scraper) scrapeAndAppendCPUTimeMetric(now pcommon.Timestamp, handle processHandle, pid int32) error { +func (s *scraper) scrapeAndAppendCPUTimeMetric(ctx context.Context, now pcommon.Timestamp, handle processHandle, pid int32) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessCPUTime.Enabled && !s.config.MetricsBuilderConfig.Metrics.ProcessCPUUtilization.Enabled { return nil } - times, err := handle.Times() + times, err := handle.TimesWithContext(ctx) if err != nil { return err } @@ -278,12 +279,12 @@ func (s *scraper) scrapeAndAppendCPUTimeMetric(now pcommon.Timestamp, handle pro return err } -func (s *scraper) scrapeAndAppendMemoryUsageMetrics(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendMemoryUsageMetrics(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !(s.config.MetricsBuilderConfig.Metrics.ProcessMemoryUsage.Enabled || s.config.MetricsBuilderConfig.Metrics.ProcessMemoryVirtual.Enabled) { return nil } - mem, err := handle.MemoryInfo() + mem, err := handle.MemoryInfoWithContext(ctx) if err != nil { return err } @@ -293,12 +294,12 @@ func (s *scraper) scrapeAndAppendMemoryUsageMetrics(now pcommon.Timestamp, handl return nil } -func (s *scraper) scrapeAndAppendMemoryUtilizationMetric(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendMemoryUtilizationMetric(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessMemoryUtilization.Enabled { return nil } - memoryPercent, err := handle.MemoryPercent() + memoryPercent, err := handle.MemoryPercentWithContext(ctx) if err != nil { return err } @@ -308,12 +309,12 @@ func (s *scraper) scrapeAndAppendMemoryUtilizationMetric(now pcommon.Timestamp, return nil } -func (s *scraper) scrapeAndAppendDiskMetrics(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendDiskMetrics(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !(s.config.MetricsBuilderConfig.Metrics.ProcessDiskIo.Enabled || s.config.MetricsBuilderConfig.Metrics.ProcessDiskOperations.Enabled) || runtime.GOOS == "darwin" { return nil } - io, err := handle.IOCounters() + io, err := handle.IOCountersWithContext(ctx) if err != nil { if s.config.MuteProcessIOError { return nil @@ -329,12 +330,12 @@ func (s *scraper) scrapeAndAppendDiskMetrics(now pcommon.Timestamp, handle proce return nil } -func (s *scraper) scrapeAndAppendPagingMetric(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendPagingMetric(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessPagingFaults.Enabled { return nil } - pageFaultsStat, err := handle.PageFaults() + pageFaultsStat, err := handle.PageFaultsWithContext(ctx) if err != nil { return err } @@ -345,11 +346,11 @@ func (s *scraper) scrapeAndAppendPagingMetric(now pcommon.Timestamp, handle proc return nil } -func (s *scraper) scrapeAndAppendThreadsMetrics(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendThreadsMetrics(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessThreads.Enabled { return nil } - threads, err := handle.NumThreads() + threads, err := handle.NumThreadsWithContext(ctx) if err != nil { return err } @@ -358,12 +359,12 @@ func (s *scraper) scrapeAndAppendThreadsMetrics(now pcommon.Timestamp, handle pr return nil } -func (s *scraper) scrapeAndAppendContextSwitchMetrics(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendContextSwitchMetrics(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessContextSwitches.Enabled { return nil } - contextSwitches, err := handle.NumCtxSwitches() + contextSwitches, err := handle.NumCtxSwitchesWithContext(ctx) if err != nil { return err @@ -375,12 +376,12 @@ func (s *scraper) scrapeAndAppendContextSwitchMetrics(now pcommon.Timestamp, han return nil } -func (s *scraper) scrapeAndAppendOpenFileDescriptorsMetric(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendOpenFileDescriptorsMetric(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessOpenFileDescriptors.Enabled { return nil } - fds, err := handle.NumFDs() + fds, err := handle.NumFDsWithContext(ctx) if err != nil { return err @@ -399,7 +400,7 @@ func (s *scraper) refreshHandleCounts() error { return s.handleCountManager.Refresh() } -func (s *scraper) scrapeAndAppendHandlesMetric(now pcommon.Timestamp, pid int64) error { +func (s *scraper) scrapeAndAppendHandlesMetric(_ context.Context, now pcommon.Timestamp, pid int64) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessHandles.Enabled { return nil } @@ -414,12 +415,12 @@ func (s *scraper) scrapeAndAppendHandlesMetric(now pcommon.Timestamp, pid int64) return nil } -func (s *scraper) scrapeAndAppendSignalsPendingMetric(now pcommon.Timestamp, handle processHandle) error { +func (s *scraper) scrapeAndAppendSignalsPendingMetric(ctx context.Context, now pcommon.Timestamp, handle processHandle) error { if !s.config.MetricsBuilderConfig.Metrics.ProcessSignalsPending.Enabled { return nil } - rlimitStats, err := handle.RlimitUsage(true) + rlimitStats, err := handle.RlimitUsageWithContext(ctx, true) if err != nil { return err } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_darwin.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_darwin.go index 2f29328750e3..93f5911882ba 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_darwin.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_darwin.go @@ -7,6 +7,7 @@ package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper" import ( + "context" "regexp" "github.com/shirou/gopsutil/v3/cpu" @@ -28,8 +29,8 @@ func (s *scraper) recordCPUUtilization(now pcommon.Timestamp, cpuUtilization uca s.mb.RecordProcessCPUUtilizationDataPoint(now, cpuUtilization.Iowait, metadata.AttributeStateWait) } -func getProcessName(proc processHandle, _ string) (string, error) { - name, err := proc.Name() +func getProcessName(ctx context.Context, proc processHandle, _ string) (string, error) { + name, err := proc.NameWithContext(ctx) if err != nil { return "", err } @@ -37,8 +38,8 @@ func getProcessName(proc processHandle, _ string) (string, error) { return name, nil } -func getProcessExecutable(proc processHandle) (string, error) { - cmdline, err := proc.Cmdline() +func getProcessExecutable(ctx context.Context, proc processHandle) (string, error) { + cmdline, err := proc.CmdlineWithContext(ctx) if err != nil { return "", err } @@ -48,8 +49,8 @@ func getProcessExecutable(proc processHandle) (string, error) { return exe, nil } -func getProcessCommand(proc processHandle) (*commandMetadata, error) { - cmdline, err := proc.Cmdline() +func getProcessCommand(ctx context.Context, proc processHandle) (*commandMetadata, error) { + cmdline, err := proc.CmdlineWithContext(ctx) if err != nil { return nil, err } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_linux.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_linux.go index cf1bbc1f032f..923a73d1244b 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_linux.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_linux.go @@ -7,6 +7,8 @@ package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper" import ( + "context" + "github.com/shirou/gopsutil/v3/cpu" "go.opentelemetry.io/collector/pdata/pcommon" @@ -26,8 +28,8 @@ func (s *scraper) recordCPUUtilization(now pcommon.Timestamp, cpuUtilization uca s.mb.RecordProcessCPUUtilizationDataPoint(now, cpuUtilization.Iowait, metadata.AttributeStateWait) } -func getProcessName(proc processHandle, _ string) (string, error) { - name, err := proc.Name() +func getProcessName(ctx context.Context, proc processHandle, _ string) (string, error) { + name, err := proc.NameWithContext(ctx) if err != nil { return "", err } @@ -35,8 +37,8 @@ func getProcessName(proc processHandle, _ string) (string, error) { return name, err } -func getProcessExecutable(proc processHandle) (string, error) { - exe, err := proc.Exe() +func getProcessExecutable(ctx context.Context, proc processHandle) (string, error) { + exe, err := proc.ExeWithContext(ctx) if err != nil { return "", err } @@ -44,8 +46,8 @@ func getProcessExecutable(proc processHandle) (string, error) { return exe, nil } -func getProcessCommand(proc processHandle) (*commandMetadata, error) { - cmdline, err := proc.CmdlineSlice() +func getProcessCommand(ctx context.Context, proc processHandle) (*commandMetadata, error) { + cmdline, err := proc.CmdlineSliceWithContext(ctx) if err != nil { return nil, err } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_others.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_others.go index 7f50497d9b3d..15c9ee9aafe2 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_others.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_others.go @@ -7,24 +7,28 @@ package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper" import ( + "context" + "github.com/shirou/gopsutil/v3/cpu" "go.opentelemetry.io/collector/pdata/pcommon" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/ucal" ) -func (s *scraper) recordCPUTimeMetric(now pcommon.Timestamp, cpuTime *cpu.TimesStat) {} +func (s *scraper) recordCPUTimeMetric(now pcommon.Timestamp, cpuTime *cpu.TimesStat) { +} -func (s *scraper) recordCPUUtilization(now pcommon.Timestamp, cpuUtilization ucal.CPUUtilization) {} +func (s *scraper) recordCPUUtilization(now pcommon.Timestamp, cpuUtilization ucal.CPUUtilization) { +} -func getProcessName(processHandle, string) (string, error) { +func getProcessName(context.Context, processHandle, string) (string, error) { return "", nil } -func getProcessExecutable(processHandle) (string, error) { +func getProcessExecutable(context.Context, processHandle) (string, error) { return "", nil } -func getProcessCommand(processHandle) (*commandMetadata, error) { +func getProcessCommand(context.Context, processHandle) (*commandMetadata, error) { return nil, nil } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go index 32034120be9f..5bb64bc03d4b 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go @@ -92,7 +92,7 @@ func TestScrape(t *testing.T) { if test.mutateScraper != nil { test.mutateScraper(scraper) } - scraper.getProcessCreateTime = func(p processHandle) (int64, error) { return createTime, nil } + scraper.getProcessCreateTime = func(p processHandle, ctx context.Context) (int64, error) { return createTime, nil } require.NoError(t, err, "Failed to create process scraper: %v", err) err = scraper.start(context.Background(), componenttest.NewNopHost()) require.NoError(t, err, "Failed to initialize process scraper: %v", err) @@ -385,112 +385,112 @@ type processHandleMock struct { mock.Mock } -func (p *processHandleMock) Name() (ret string, err error) { - args := p.MethodCalled("Name") +func (p *processHandleMock) NameWithContext(ctx context.Context) (ret string, err error) { + args := p.MethodCalled("NameWithContext", ctx) return args.String(0), args.Error(1) } -func (p *processHandleMock) Exe() (string, error) { - args := p.MethodCalled("Exe") +func (p *processHandleMock) ExeWithContext(ctx context.Context) (string, error) { + args := p.MethodCalled("ExeWithContext", ctx) return args.String(0), args.Error(1) } -func (p *processHandleMock) Username() (string, error) { - args := p.MethodCalled("Username") +func (p *processHandleMock) UsernameWithContext(ctx context.Context) (string, error) { + args := p.MethodCalled("UsernameWithContext", ctx) return args.String(0), args.Error(1) } -func (p *processHandleMock) Cmdline() (string, error) { - args := p.MethodCalled("Cmdline") +func (p *processHandleMock) CmdlineWithContext(ctx context.Context) (string, error) { + args := p.MethodCalled("CmdlineWithContext", ctx) return args.String(0), args.Error(1) } -func (p *processHandleMock) CmdlineSlice() ([]string, error) { - args := p.MethodCalled("CmdlineSlice") +func (p *processHandleMock) CmdlineSliceWithContext(ctx context.Context) ([]string, error) { + args := p.MethodCalled("CmdlineSliceWithContext", ctx) return args.Get(0).([]string), args.Error(1) } -func (p *processHandleMock) Times() (*cpu.TimesStat, error) { - args := p.MethodCalled("Times") +func (p *processHandleMock) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) { + args := p.MethodCalled("TimesWithContext", ctx) return args.Get(0).(*cpu.TimesStat), args.Error(1) } -func (p *processHandleMock) Percent(time.Duration) (float64, error) { - args := p.MethodCalled("Percent") +func (p *processHandleMock) PercentWithContext(ctx context.Context, d time.Duration) (float64, error) { + args := p.MethodCalled("PercentWithContext", ctx, d) return args.Get(0).(float64), args.Error(1) } -func (p *processHandleMock) MemoryInfo() (*process.MemoryInfoStat, error) { - args := p.MethodCalled("MemoryInfo") +func (p *processHandleMock) MemoryInfoWithContext(ctx context.Context) (*process.MemoryInfoStat, error) { + args := p.MethodCalled("MemoryInfoWithContext", ctx) return args.Get(0).(*process.MemoryInfoStat), args.Error(1) } -func (p *processHandleMock) MemoryPercent() (float32, error) { - args := p.MethodCalled("MemoryPercent") +func (p *processHandleMock) MemoryPercentWithContext(ctx context.Context) (float32, error) { + args := p.MethodCalled("MemoryPercentWithContext", ctx) return args.Get(0).(float32), args.Error(1) } -func (p *processHandleMock) IOCounters() (*process.IOCountersStat, error) { - args := p.MethodCalled("IOCounters") +func (p *processHandleMock) IOCountersWithContext(ctx context.Context) (*process.IOCountersStat, error) { + args := p.MethodCalled("IOCountersWithContext", ctx) return args.Get(0).(*process.IOCountersStat), args.Error(1) } -func (p *processHandleMock) NumThreads() (int32, error) { - args := p.MethodCalled("NumThreads") +func (p *processHandleMock) NumThreadsWithContext(ctx context.Context) (int32, error) { + args := p.MethodCalled("NumThreadsWithContext", ctx) return args.Get(0).(int32), args.Error(1) } -func (p *processHandleMock) CreateTime() (int64, error) { - args := p.MethodCalled("CreateTime") +func (p *processHandleMock) CreateTimeWithContext(ctx context.Context) (int64, error) { + args := p.MethodCalled("CreateTimeWithContext", ctx) return args.Get(0).(int64), args.Error(1) } -func (p *processHandleMock) Parent() (*process.Process, error) { - args := p.MethodCalled("Parent") +func (p *processHandleMock) ParentWithContext(ctx context.Context) (*process.Process, error) { + args := p.MethodCalled("ParentWithContext", ctx) return args.Get(0).(*process.Process), args.Error(1) } -func (p *processHandleMock) Ppid() (int32, error) { - args := p.MethodCalled("Ppid") +func (p *processHandleMock) PpidWithContext(ctx context.Context) (int32, error) { + args := p.MethodCalled("PpidWithContext", ctx) return args.Get(0).(int32), args.Error(1) } -func (p *processHandleMock) PageFaults() (*process.PageFaultsStat, error) { - args := p.MethodCalled("PageFaults") +func (p *processHandleMock) PageFaultsWithContext(ctx context.Context) (*process.PageFaultsStat, error) { + args := p.MethodCalled("PageFaultsWithContext", ctx) return args.Get(0).(*process.PageFaultsStat), args.Error(1) } -func (p *processHandleMock) NumCtxSwitches() (*process.NumCtxSwitchesStat, error) { - args := p.MethodCalled("NumCtxSwitches") +func (p *processHandleMock) NumCtxSwitchesWithContext(ctx context.Context) (*process.NumCtxSwitchesStat, error) { + args := p.MethodCalled("NumCtxSwitchesWithContext", ctx) return args.Get(0).(*process.NumCtxSwitchesStat), args.Error(1) } -func (p *processHandleMock) NumFDs() (int32, error) { - args := p.MethodCalled("NumFDs") +func (p *processHandleMock) NumFDsWithContext(ctx context.Context) (int32, error) { + args := p.MethodCalled("NumFDsWithContext", ctx) return args.Get(0).(int32), args.Error(1) } -func (p *processHandleMock) RlimitUsage(_ bool) ([]process.RlimitStat, error) { - args := p.MethodCalled("RlimitUsage") +func (p *processHandleMock) RlimitUsageWithContext(ctx context.Context, b bool) ([]process.RlimitStat, error) { + args := p.MethodCalled("RlimitUsageWithContext", ctx, b) return args.Get(0).([]process.RlimitStat), args.Error(1) } func newDefaultHandleMock() *processHandleMock { handleMock := &processHandleMock{} - handleMock.On("Username").Return("username", nil) - handleMock.On("Cmdline").Return("cmdline", nil) - handleMock.On("CmdlineSlice").Return([]string{"cmdline"}, nil) - handleMock.On("Times").Return(&cpu.TimesStat{}, nil) - handleMock.On("Percent").Return(float64(0), nil) - handleMock.On("MemoryInfo").Return(&process.MemoryInfoStat{}, nil) - handleMock.On("MemoryPercent").Return(float32(0), nil) - handleMock.On("IOCounters").Return(&process.IOCountersStat{}, nil) - handleMock.On("Ppid").Return(int32(2), nil) - handleMock.On("NumThreads").Return(int32(0), nil) - handleMock.On("PageFaults").Return(&process.PageFaultsStat{}, nil) - handleMock.On("NumCtxSwitches").Return(&process.NumCtxSwitchesStat{}, nil) - handleMock.On("NumFDs").Return(int32(0), nil) - handleMock.On("RlimitUsage").Return([]process.RlimitStat{}, nil) + handleMock.On("UsernameWithContext", mock.Anything).Return("username", nil) + handleMock.On("CmdlineWithContext", mock.Anything).Return("cmdline", nil) + handleMock.On("CmdlineSliceWithContext", mock.Anything).Return([]string{"cmdline"}, nil) + handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, nil) + handleMock.On("PercentWithContext", mock.Anything, mock.Anything).Return(float64(0), nil) + handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, nil) + handleMock.On("MemoryPercentWithContext", mock.Anything).Return(float32(0), nil) + handleMock.On("IOCountersWithContext", mock.Anything).Return(&process.IOCountersStat{}, nil) + handleMock.On("PpidWithContext", mock.Anything).Return(int32(2), nil) + handleMock.On("NumThreadsWithContext", mock.Anything).Return(int32(0), nil) + handleMock.On("PageFaultsWithContext", mock.Anything).Return(&process.PageFaultsStat{}, nil) + handleMock.On("NumCtxSwitchesWithContext", mock.Anything).Return(&process.NumCtxSwitchesStat{}, nil) + handleMock.On("NumFDsWithContext", mock.Anything).Return(int32(0), nil) + handleMock.On("RlimitUsageWithContext", mock.Anything, mock.Anything).Return([]process.RlimitStat{}, nil) return handleMock } @@ -599,9 +599,9 @@ func TestScrapeMetrics_Filtered(t *testing.T) { handles := make([]*processHandleMock, 0, len(test.names)) for i, name := range test.names { handleMock := newDefaultHandleMock() - handleMock.On("Name").Return(name, nil) - handleMock.On("Exe").Return(name, nil) - handleMock.On("CreateTime").Return(time.Now().UnixMilli()-test.upTimeMs[i], nil) + handleMock.On("NameWithContext", mock.Anything).Return(name, nil) + handleMock.On("ExeWithContext", mock.Anything).Return(name, nil) + handleMock.On("CreateTimeWithContext", mock.Anything).Return(time.Now().UnixMilli()-test.upTimeMs[i], nil) handles = append(handles, handleMock) } @@ -812,23 +812,23 @@ func TestScrapeMetrics_ProcessErrors(t *testing.T) { } handleMock := &processHandleMock{} - handleMock.On("Name").Return("test", test.nameError) - handleMock.On("Exe").Return("test", test.exeError) - handleMock.On("Username").Return(username, test.usernameError) - handleMock.On("Cmdline").Return("cmdline", test.cmdlineError) - handleMock.On("CmdlineSlice").Return([]string{"cmdline"}, test.cmdlineError) - handleMock.On("Times").Return(&cpu.TimesStat{}, test.timesError) - handleMock.On("Percent").Return(float64(0), nil) - handleMock.On("MemoryInfo").Return(&process.MemoryInfoStat{}, test.memoryInfoError) - handleMock.On("MemoryPercent").Return(float32(0), test.memoryPercentError) - handleMock.On("IOCounters").Return(&process.IOCountersStat{}, test.ioCountersError) - handleMock.On("CreateTime").Return(int64(0), test.createTimeError) - handleMock.On("Ppid").Return(int32(2), test.parentPidError) - handleMock.On("NumThreads").Return(int32(0), test.numThreadsError) - handleMock.On("PageFaults").Return(&process.PageFaultsStat{}, test.pageFaultsError) - handleMock.On("NumCtxSwitches").Return(&process.NumCtxSwitchesStat{}, test.numCtxSwitchesError) - handleMock.On("NumFDs").Return(int32(0), test.numFDsError) - handleMock.On("RlimitUsage").Return([]process.RlimitStat{ + handleMock.On("NameWithContext", mock.Anything).Return("test", test.nameError) + handleMock.On("ExeWithContext", mock.Anything).Return("test", test.exeError) + handleMock.On("UsernameWithContext", mock.Anything).Return(username, test.usernameError) + handleMock.On("CmdlineWithContext", mock.Anything).Return("cmdline", test.cmdlineError) + handleMock.On("CmdlineSliceWithContext", mock.Anything).Return([]string{"cmdline"}, test.cmdlineError) + handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, test.timesError) + handleMock.On("PercentWithContext", mock.Anything).Return(float64(0), nil) + handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, test.memoryInfoError) + handleMock.On("MemoryPercentWithContext", mock.Anything).Return(float32(0), test.memoryPercentError) + handleMock.On("IOCountersWithContext", mock.Anything).Return(&process.IOCountersStat{}, test.ioCountersError) + handleMock.On("CreateTimeWithContext", mock.Anything).Return(int64(0), test.createTimeError) + handleMock.On("PpidWithContext", mock.Anything).Return(int32(2), test.parentPidError) + handleMock.On("NumThreadsWithContext", mock.Anything).Return(int32(0), test.numThreadsError) + handleMock.On("PageFaultsWithContext", mock.Anything).Return(&process.PageFaultsStat{}, test.pageFaultsError) + handleMock.On("NumCtxSwitchesWithContext", mock.Anything).Return(&process.NumCtxSwitchesStat{}, test.numCtxSwitchesError) + handleMock.On("NumFDsWithContext", mock.Anything).Return(int32(0), test.numFDsError) + handleMock.On("RlimitUsageWithContext", mock.Anything, mock.Anything).Return([]process.RlimitStat{ { Resource: process.RLIMIT_SIGPENDING, Used: 0, @@ -1010,12 +1010,12 @@ func TestScrapeMetrics_MuteErrorFlags(t *testing.T) { require.NoError(t, err, "Failed to initialize process scraper: %v", err) handleMock := &processHandleMock{} - handleMock.On("Name").Return("test", processNameError) - handleMock.On("Exe").Return("test", processNameError) - handleMock.On("Cmdline").Return("test", processNameError) + handleMock.On("NameWithContext", mock.Anything).Return("test", processNameError) + handleMock.On("ExeWithContext", mock.Anything).Return("test", processNameError) + handleMock.On("CmdlineWithContext", mock.Anything).Return("test", processNameError) if config.MuteProcessIOError { - handleMock.On("IOCounters").Return("test", errors.New("permission denied")) + handleMock.On("IOCountersWithContext", mock.Anything).Return("test", errors.New("permission denied")) } scraper.getProcessHandles = func(context.Context) (processHandles, error) { @@ -1042,16 +1042,16 @@ func (m *ProcessReadError) Error() string { func newErroringHandleMock() *processHandleMock { handleMock := &processHandleMock{} - handleMock.On("Username").Return("username", nil) - handleMock.On("Cmdline").Return("cmdline", nil) - handleMock.On("CmdlineSlice").Return([]string{"cmdline"}, nil) - handleMock.On("Times").Return(&cpu.TimesStat{}, &ProcessReadError{}) - handleMock.On("Percent").Return(float64(0), nil) - handleMock.On("MemoryInfo").Return(&process.MemoryInfoStat{}, &ProcessReadError{}) - handleMock.On("IOCounters").Return(&process.IOCountersStat{}, &ProcessReadError{}) - handleMock.On("NumThreads").Return(int32(0), &ProcessReadError{}) - handleMock.On("NumCtxSwitches").Return(&process.NumCtxSwitchesStat{}, &ProcessReadError{}) - handleMock.On("NumFDs").Return(int32(0), &ProcessReadError{}) + handleMock.On("UsernameWithContext", mock.Anything).Return("username", nil) + handleMock.On("CmdlineWithContext", mock.Anything).Return("cmdline", nil) + handleMock.On("CmdlineSliceWithContext", mock.Anything).Return([]string{"cmdline"}, nil) + handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, &ProcessReadError{}) + handleMock.On("PercentWithContext", mock.Anything).Return(float64(0), nil) + handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, &ProcessReadError{}) + handleMock.On("IOCountersWithContext", mock.Anything).Return(&process.IOCountersStat{}, &ProcessReadError{}) + handleMock.On("NumThreadsWithContext", mock.Anything).Return(int32(0), &ProcessReadError{}) + handleMock.On("NumCtxSwitchesWithContext", mock.Anything).Return(&process.NumCtxSwitchesStat{}, &ProcessReadError{}) + handleMock.On("NumFDsWithContext", mock.Anything).Return(int32(0), &ProcessReadError{}) return handleMock } @@ -1075,10 +1075,10 @@ func TestScrapeMetrics_DontCheckDisabledMetrics(t *testing.T) { require.NoError(t, err, "Failed to initialize process scraper: %v", err) handleMock := newErroringHandleMock() - handleMock.On("Name").Return("test", nil) - handleMock.On("Exe").Return("test", nil) - handleMock.On("CreateTime").Return(time.Now().UnixMilli(), nil) - handleMock.On("Ppid").Return(int32(2), nil) + handleMock.On("NameWithContext", mock.Anything).Return("test", nil) + handleMock.On("ExeWithContext", mock.Anything).Return("test", nil) + handleMock.On("CreateTimeWithContext", mock.Anything).Return(time.Now().UnixMilli(), nil) + handleMock.On("PpidWithContext", mock.Anything).Return(int32(2), nil) scraper.getProcessHandles = func(context.Context) (processHandles, error) { return &processHandlesMock{handles: []*processHandleMock{handleMock}}, nil @@ -1144,9 +1144,9 @@ func TestScrapeMetrics_CpuUtilizationWhenCpuTimesIsDisabled(t *testing.T) { require.NoError(t, err, "Failed to initialize process scraper: %v", err) handleMock := newDefaultHandleMock() - handleMock.On("Name").Return("test", nil) - handleMock.On("Exe").Return("test", nil) - handleMock.On("CreateTime").Return(time.Now().UnixMilli(), nil) + handleMock.On("NameWithContext", mock.Anything).Return("test", nil) + handleMock.On("ExeWithContext", mock.Anything).Return("test", nil) + handleMock.On("CreateTimeWithContext", mock.Anything).Return(time.Now().UnixMilli(), nil) scraper.getProcessHandles = func(context.Context) (processHandles, error) { return &processHandlesMock{handles: []*processHandleMock{handleMock}}, nil diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_windows.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_windows.go index ad9ef8c061e3..b9f68598c4b8 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_windows.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_windows.go @@ -7,6 +7,7 @@ package processscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper" import ( + "context" "fmt" "path/filepath" "regexp" @@ -28,7 +29,7 @@ func (s *scraper) recordCPUUtilization(now pcommon.Timestamp, cpuUtilization uca s.mb.RecordProcessCPUUtilizationDataPoint(now, cpuUtilization.System, metadata.AttributeStateSystem) } -func getProcessName(_ processHandle, exePath string) (string, error) { +func getProcessName(_ context.Context, _ processHandle, exePath string) (string, error) { if exePath == "" { return "", fmt.Errorf("executable path is empty") } @@ -36,8 +37,8 @@ func getProcessName(_ processHandle, exePath string) (string, error) { return filepath.Base(exePath), nil } -func getProcessExecutable(proc processHandle) (string, error) { - exe, err := proc.Exe() +func getProcessExecutable(ctx context.Context, proc processHandle) (string, error) { + exe, err := proc.ExeWithContext(ctx) if err != nil { return "", err } @@ -48,8 +49,8 @@ func getProcessExecutable(proc processHandle) (string, error) { // matches the first argument before an unquoted space or slash var cmdRegex = regexp.MustCompile(`^((?:[^"]*?"[^"]*?")*?[^"]*?)(?:[ \/]|$)`) -func getProcessCommand(proc processHandle) (*commandMetadata, error) { - cmdline, err := proc.Cmdline() +func getProcessCommand(ctx context.Context, proc processHandle) (*commandMetadata, error) { + cmdline, err := proc.CmdlineWithContext(ctx) if err != nil { return nil, err } diff --git a/receiver/hostmetricsreceiver/testdata/e2e/expected_process.yaml b/receiver/hostmetricsreceiver/testdata/e2e/expected_process.yaml new file mode 100644 index 000000000000..1f9c0696ced1 --- /dev/null +++ b/receiver/hostmetricsreceiver/testdata/e2e/expected_process.yaml @@ -0,0 +1,151 @@ +resourceMetrics: + - resource: + attributes: + - key: process.command + value: + stringValue: /bin/sleep 300 + - key: process.command_line + value: + stringValue: /bin/sleep 300 + - key: process.executable.name + value: + stringValue: sleep + - key: process.executable.path + value: + stringValue: /bin/sleep + - key: process.owner + value: + stringValue: atoulme + - key: process.parent_pid + value: + intValue: "95040" + - key: process.pid + value: + intValue: "95041" + schemaUrl: https://opentelemetry.io/schemas/1.9.0 + scopeMetrics: + - metrics: + - description: Total CPU seconds broken down by different states. + name: process.cpu.time + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0.0012836666666666665 + attributes: + - key: state + value: + stringValue: system + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0.00037095833333333333 + attributes: + - key: state + value: + stringValue: user + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0 + attributes: + - key: state + value: + stringValue: wait + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + isMonotonic: true + unit: s + - description: The amount of physical memory in use. + name: process.memory.usage + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "1064960" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + - description: Virtual memory size. + name: process.memory.virtual + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "418299674624" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + scope: + name: otelcol/hostmetricsreceiver/process + version: latest + - resource: + attributes: + - key: process.command + value: + stringValue: sleep 31536000 + - key: process.command_line + value: + stringValue: sleep 31536000 + - key: process.executable.name + value: + stringValue: sleep + - key: process.executable.path + value: + stringValue: sleep + - key: process.owner + value: + stringValue: atoulme + - key: process.parent_pid + value: + intValue: "4654" + - key: process.pid + value: + intValue: "4668" + schemaUrl: https://opentelemetry.io/schemas/1.9.0 + scopeMetrics: + - metrics: + - description: Total CPU seconds broken down by different states. + name: process.cpu.time + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0.0030173333333333332 + attributes: + - key: state + value: + stringValue: system + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0.0006898333333333332 + attributes: + - key: state + value: + stringValue: user + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0 + attributes: + - key: state + value: + stringValue: wait + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + isMonotonic: true + unit: s + - description: The amount of physical memory in use. + name: process.memory.usage + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "311296" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + - description: Virtual memory size. + name: process.memory.virtual + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "418299674624" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + scope: + name: otelcol/hostmetricsreceiver/process + version: latest diff --git a/receiver/hostmetricsreceiver/testdata/e2e/expected_process_separate_proc.yaml b/receiver/hostmetricsreceiver/testdata/e2e/expected_process_separate_proc.yaml new file mode 100644 index 000000000000..4fa00fa3bc8b --- /dev/null +++ b/receiver/hostmetricsreceiver/testdata/e2e/expected_process_separate_proc.yaml @@ -0,0 +1,76 @@ +resourceMetrics: + - resource: + attributes: + - key: process.command + value: + stringValue: sleep 31536000 + - key: process.command_line + value: + stringValue: sleep 31536000 + - key: process.executable.name + value: + stringValue: sleep + - key: process.executable.path + value: + stringValue: sleep + - key: process.owner + value: + stringValue: atoulme + - key: process.parent_pid + value: + intValue: "4654" + - key: process.pid + value: + intValue: "4668" + schemaUrl: https://opentelemetry.io/schemas/1.9.0 + scopeMetrics: + - metrics: + - description: Total CPU seconds broken down by different states. + name: process.cpu.time + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 0.0030173333333333332 + attributes: + - key: state + value: + stringValue: system + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0.0006898333333333332 + attributes: + - key: state + value: + stringValue: user + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + - asDouble: 0 + attributes: + - key: state + value: + stringValue: wait + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + isMonotonic: true + unit: s + - description: The amount of physical memory in use. + name: process.memory.usage + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "311296" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + - description: Virtual memory size. + name: process.memory.virtual + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "418299674624" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: By + scope: + name: otelcol/hostmetricsreceiver/process + version: latest diff --git a/receiver/hostmetricsreceiver/testdata/e2e/proc/1/cmdline b/receiver/hostmetricsreceiver/testdata/e2e/proc/1/cmdline new file mode 100644 index 000000000000..5d4150d089af --- /dev/null +++ b/receiver/hostmetricsreceiver/testdata/e2e/proc/1/cmdline @@ -0,0 +1 @@ +/bin/bash \ No newline at end of file diff --git a/receiver/hostmetricsreceiver/testdata/e2e/proc/1/stat b/receiver/hostmetricsreceiver/testdata/e2e/proc/1/stat new file mode 100644 index 000000000000..10a434792ec7 --- /dev/null +++ b/receiver/hostmetricsreceiver/testdata/e2e/proc/1/stat @@ -0,0 +1 @@ +1 (bash) S 0 1 1 34816 13 4194560 1129 0 2 0 0 0 0 0 20 0 1 0 1386 4153344 808 18446744073709551615 187650802057216 187650803328712 281473965360240 0 0 0 65536 3686404 1266761467 1 0 0 17 4 0 0 0 0 0 187650803415808 187650803467196 187651517526016 281473965363062 281473965363072 281473965363072 281473965363182 0 \ No newline at end of file diff --git a/receiver/hostmetricsreceiver/testdata/e2e/proc/stat b/receiver/hostmetricsreceiver/testdata/e2e/proc/stat new file mode 100644 index 000000000000..fd7f37c878c7 --- /dev/null +++ b/receiver/hostmetricsreceiver/testdata/e2e/proc/stat @@ -0,0 +1,13 @@ +cpu 342 0 566 73488 89 0 27 0 0 0 +cpu0 127 0 80 14666 8 0 16 0 0 0 +cpu1 59 0 192 14635 19 0 3 0 0 0 +cpu2 55 0 97 14719 21 0 3 0 0 0 +cpu3 49 0 106 14725 20 0 2 0 0 0 +cpu4 51 0 89 14742 20 0 1 0 0 0 +intr 162318 0 61154 2312 0 0 0 2 0 0 0 0 86462 0 0 0 134 488 9255 3 3 3 3 3 2461 4 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +ctxt 271542 +btime 1693963648 +processes 2085 +procs_running 3 +procs_blocked 0 +softirq 42212 0 3848 11 348 12980 0 1 8309 0 16715 \ No newline at end of file