diff --git a/.goreleaser.yml b/.goreleaser.yml index 6fb4b062..d5f2f138 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,125 +1,180 @@ project_name: circonus-agent before: - hooks: - - go mod tidy - - ./build_lint.sh - - ./build_plugins.sh + hooks: + - go mod tidy + - ./build_lint.sh + - ./build_plugins.sh builds: - - - id: circonus-agent - main: main.go - binary: sbin/circonus-agentd - env: - - CGO_ENABLED=0 - flags: - #- -a - goos: - - linux - - darwin - - windows - - freebsd - - openbsd - - solaris - - illumos - - goarch: - - amd64 - - arm64 - - arm - - ignore: - - - goarch: 386 - - goos: freebsd - goarch: arm - - goos: openbsd - goarch: arm64 - - goos: openbsd - goarch: arm - - goos: windows - goarch: arm - - goos: windows - goarch: arm64 - - - ldflags: - - -X github.com/circonus-labs/circonus-agent/internal/release.VERSION={{.Version}} - - -X github.com/circonus-labs/circonus-agent/internal/release.COMMIT={{.ShortCommit}} - - -X github.com/circonus-labs/circonus-agent/internal/release.DATE={{.Date}} - - -X github.com/circonus-labs/circonus-agent/internal/release.TAG={{.Tag}} + - id: circonus-agent + main: main.go + binary: sbin/circonus-agentd + env: + - CGO_ENABLED=0 + flags: + - -trimpath + goos: + - linux + - windows + - freebsd + - openbsd + - solaris + - illumos + goarch: + - amd64 + - arm64 + - arm + ignore: + - + goarch: 386 + - goos: freebsd + goarch: arm + - goos: openbsd + goarch: arm64 + - goos: openbsd + goarch: arm + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + ldflags: + - -s + - -w + - -extldflags "-static" + - -X github.com/circonus-labs/circonus-agent/internal/release.VERSION={{.Version}} + - -X github.com/circonus-labs/circonus-agent/internal/release.COMMIT={{.ShortCommit}} + - -X github.com/circonus-labs/circonus-agent/internal/release.DATE={{.Date}} + - -X github.com/circonus-labs/circonus-agent/internal/release.TAG={{.Tag}} + + - id: ca-macos_amd64 + main: main.go + binary: sbin/circonus-agentd + env: + - CGO_ENABLED=0 + flags: + - -trimpath + goos: + - darwin + goarch: + - amd64 + ldflags: + - -s + - -w + - -extldflags "-static" + - -X github.com/circonus-labs/circonus-agent/internal/release.VERSION={{.Version}} + - -X github.com/circonus-labs/circonus-agent/internal/release.COMMIT={{.ShortCommit}} + - -X github.com/circonus-labs/circonus-agent/internal/release.DATE={{.Date}} + - -X github.com/circonus-labs/circonus-agent/internal/release.TAG={{.Tag}} + hooks: + post: ./macos_sign.sh {{ .Path }} + + - id: ca-macos_arm64 + main: main.go + binary: sbin/circonus-agentd + env: + - CGO_ENABLED=0 + flags: + - -trimpath + goos: + - darwin + goarch: + - arm64 + ldflags: + - -s + - -w + - -extldflags "-static" + - -X github.com/circonus-labs/circonus-agent/internal/release.VERSION={{.Version}} + - -X github.com/circonus-labs/circonus-agent/internal/release.COMMIT={{.ShortCommit}} + - -X github.com/circonus-labs/circonus-agent/internal/release.DATE={{.Date}} + - -X github.com/circonus-labs/circonus-agent/internal/release.TAG={{.Tag}} + hooks: + post: ./macos_sign.sh {{ .Path }} dockers: - - - goos: linux - goarch: amd64 - goarm: '' - ids: ['circonus-agent'] - image_templates: - - "circonus/{{.ProjectName}}:{{.Tag}}-amd64" - - "circonus/{{.ProjectName}}:latest-amd64" - skip_push: false - dockerfile: clusters/docker/x86_64/Dockerfile - build_flag_templates: - - "--label=org.label-schema.schema-version=1.0" - - "--label=org.label-schema.version={{.Version}}" - - "--label=org.label-schema.name={{.ProjectName}}" - - - goos: linux - goarch: arm64 - goarm: '' - ids: ['circonus-agent'] - image_templates: - - "circonus/{{.ProjectName}}:{{.Tag}}-arm64" - - "circonus/{{.ProjectName}}:latest-arm64" - skip_push: false - dockerfile: clusters/docker/arm64/Dockerfile - build_flag_templates: - - "--label=org.label-schema.schema-version=1.0" - - "--label=org.label-schema.version={{.Version}}" - - "--label=org.label-schema.name={{.ProjectName}}" + - id: ca-amd64 + goos: linux + goarch: amd64 + goarm: '' + ids: ['circonus-agent'] + image_templates: + - "circonus/{{.ProjectName}}:{{.Tag}}-amd64" + - "circonus/{{.ProjectName}}:latest-amd64" + skip_push: false + dockerfile: clusters/docker/x86_64/Dockerfile + build_flag_templates: + - "--label=org.label-schema.schema-version=1.0" + - "--label=org.label-schema.version={{.Version}}" + - "--label=org.label-schema.name={{.ProjectName}}" + + - id: ca-arm64 + goos: linux + goarch: arm64 + goarm: '' + ids: ['circonus-agent'] + image_templates: + - "circonus/{{.ProjectName}}:{{.Tag}}-arm64" + - "circonus/{{.ProjectName}}:latest-arm64" + skip_push: false + dockerfile: clusters/docker/arm64/Dockerfile + build_flag_templates: + - "--label=org.label-schema.schema-version=1.0" + - "--label=org.label-schema.version={{.Version}}" + - "--label=org.label-schema.name={{.ProjectName}}" docker_manifests: - - name_template: "circonus/{{.ProjectName}}:latest" - image_templates: - - "circonus/{{.ProjectName}}:latest-amd64" - - "circonus/{{.ProjectName}}:latest-arm64" - - name_template: "circonus/{{.ProjectName}}:{{.Tag}}" - image_templates: - - "circonus/{{.ProjectName}}:{{.Tag}}-amd64" - - "circonus/{{.ProjectName}}:{{.Tag}}-arm64" + - name_template: "circonus/{{.ProjectName}}:latest" + image_templates: + - "circonus/{{.ProjectName}}:latest-amd64" + - "circonus/{{.ProjectName}}:latest-arm64" + - name_template: "circonus/{{.ProjectName}}:{{.Tag}}" + image_templates: + - "circonus/{{.ProjectName}}:{{.Tag}}-amd64" + - "circonus/{{.ProjectName}}:{{.Tag}}-arm64" archives: - - - id: default - name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}" - - format: tar.gz - - replacements: - amd64: x86_64 - - format_overrides: - - - goos: windows - format: zip - - files: - - LICENSE - - README.md - - CHANGELOG.md - - etc/README.md - - service/* - - cache/README.md - - plugins/**/* + - id: default + name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}_{{.Arch}}" + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE + - README.md + - CHANGELOG.md + - etc/README.md + - service/* + - cache/README.md + - plugins/**/* release: - github: - owner: circonus-labs - name: circonus-agent - - prerelease: false + github: + owner: circonus-labs + name: circonus-agent + draft: false + prerelease: false + +changelog: + use: git + sort: desc + abbrev: 0 + groups: + - title: Features + regexp: "^.*feat[(\\w)]*:+.*$" + order: 0 + - title: 'Bug fixes' + regexp: "^.*fix[(\\w)]*:+.*$" + order: 1 + - title: 'Dependencies' + regexp: "^.*build(deps):+.*$" + order: 2 + - title: Others + order: 999 + filters: + exclude: + - '^docs:' + - typo checksum: - name_template: "{{.ProjectName}}_checksums.txt" + name_template: "{{.ProjectName}}_checksums.txt" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a26618e..f2eebf45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,28 @@ +# v2.7.0 + +* chore(lint): struct member alignment +* chore: remove timed refresh for reverse. use only primary broker check. +* build(deps): upgrade cgm to v3.4.7 +* build(deps): bump github.com/google/uuid from 1.3.1 to 1.4.0 +* build(deps): bump github.com/prometheus/common from 0.44.0 to 0.45.0 +* build(deps): bump github.com/spf13/viper from 1.16.0 to 1.17.0 +* build(deps): bump github.com/spf13/cobra from 1.7.0 to 1.8.0 +* build(deps): bump golang.org/x/sync from 0.3.0 to 0.5.0 +* build(deps): bump golang.org/x/sys from 0.12.0 to 0.14.0 +* build(deps): bump github.com/prometheus/client_model from 0.4.0 to 0.5.0 +* build(deps): bump github.com/shirou/gopsutil/v3 from 3.23.8 to 3.23.9 +* build(deps): bump github.com/rs/zerolog from 1.30.0 to 1.31.0 +* build(deps): bump github.com/hashicorp/go-retryablehttp from 0.7.2 to 0.7.4 +* build(deps): bump github.com/circonus-labs/go-apiclient from 0.7.18 to 0.7.23 +* build(deps): bump github.com/shirou/gopsutil/v3 from 3.23.9 to 3.23.10 + # v2.6.0 * fix(receiver): add SerializeB64 handling for histograms to the `/write` endpoint * feat: `/options` endpoint to dynamically control log_level (e.g. turn debug on/off while running) * feat(statsd): explicit metric parsing debug option * fix: don't swallow sigpipe -* fix(lint): unsed args (generic, linux, & windows) +* fix(lint): unused args (generic, linux, & windows) * chore: golangci-lint v1.52 * fix(lint): exports annotated with json tag * fix(lint): redundant if-return @@ -49,14 +67,14 @@ # v2.4.2 -* fix!: error handling on read timemout (reverse) +* fix!: error handling on read timeout (reverse) * upd!: dependencies (apiclient, cgm) -- for performance optimized openhistogram * doc: note for automation with --check-delete * add: last conn/retry/err stats * add: last run req stat -* upd: disable fieldalignment (automated lint) +* upd: disable field alignment (automated lint) * wip: nfpm -* upd: explict paths for fb +* upd: explicit paths for fb * upd: remove transitory downloads * upd: ownership for etc dir fb tgz * add: dependabot.yml @@ -113,7 +131,7 @@ # v2.3.0 -* upd: adjust statsd rate hadnling to match broker +* upd: adjust statsd rate handling to match broker * fix: error handling in reverse # v2.2.1 @@ -146,7 +164,7 @@ # v2.0.2 -* upd: change [dockerhub organization](https://hub.docker.com/repository/docker/circonus/circonus-agent) circonuslabs->circonus +* upd: change [docker hub organization](https://hub.docker.com/repository/docker/circonus/circonus-agent) circonuslabs->circonus # v2.0.1 @@ -171,18 +189,18 @@ Note: For automatic host dashboards a new check type is being used. This makes t * fix: use api ca file if specified for check api client * add: generic hostTags method for check tags (applies to create and update) * add: host tags to check (like cosi did) -* fix: only lower case category if not already encoded (affected receiver w/streamtagged metric names) +* fix: only lower case category if not already encoded (affected receiver w/stream tagged metric names) * upd: go1.15 manual tls VerifyConnection -* upd: depedencies +* upd: dependencies * fix: config file path sep to be os sensitive # v1.1.0 * doc: add multi-agent details -* fix: linit align structs +* fix: lint align struct fields * fix: lint for rand * add: support tag merging for receiver -* upd: remove deprecated state mgmt +* upd: remove deprecated state management * add: force enterprise for multi-agent mode * add: verify httptrap is enabled on broker for multi-agent mode * add: SubmissionURL method for multi-agent @@ -222,7 +240,7 @@ Note: For automatic host dashboards a new check type is being used. This makes t # v1.0.11 -* upd: if multiple checks found matching criteria (active,json:nad,target) and none match the agent, return result such that a check will be created (if create check is enabled) - note, this does present the possiblity of multiple checks being created if the notes are altered in such a way that the agent is not able to determine it created the check +* upd: if multiple checks found matching criteria (active,json:nad,target) and none match the agent, return result such that a check will be created (if create check is enabled) - note, this does present the possibility of multiple checks being created if the notes are altered in such a way that the agent is not able to determine it created the check # v1.0.10 @@ -343,16 +361,16 @@ Note: For automatic host dashboards a new check type is being used. This makes t * add: example metric filter using tags * fix: lint, duplicate toml (one should be yaml) * fix: lint, use `fmt.Println` vs `fmt.Printf` in test -* fix: lint, remove old `id`, replaced with streamtag `collector:promrecv` +* fix: lint, remove old `id`, replaced with stream tag `collector:promrecv` * fix: generic builtins, skip NaN floats (causes json error) * upd: dependencies * add: smf manifest # v1.0.0-beta.1 -* fix: output all parsed plugin metrics with streamtags, include any tags from `_tags` attribute of emitted json +* fix: output all parsed plugin metrics with stream tags, include any tags from `_tags` attribute of emitted json * fix: output tags `io_latency` in `_tags` attribute rather than in metric name (so they can be combined with agent tags to create stream tagged metric name) -* add: statsd tcp listner (optional, off by default) +* add: statsd tcp listener (optional, off by default) # v1.0.0-alpha.5 diff --git a/clusters/docker/arm64/Dockerfile b/clusters/docker/arm64/Dockerfile index b6e73b96..3c8a2790 100644 --- a/clusters/docker/arm64/Dockerfile +++ b/clusters/docker/arm64/Dockerfile @@ -1,6 +1,6 @@ FROM arm64v8/alpine:latest -COPY circonus-agentd / +ADD . /ca # NOTE: these are the default ports, use -p to map alternatives configured EXPOSE 2609/tcp EXPOSE 8125/udp -ENTRYPOINT ["/circonus-agentd"] \ No newline at end of file +ENTRYPOINT ["/ca/sbin/circonus-agentd"] \ No newline at end of file diff --git a/clusters/docker/x86_64/Dockerfile b/clusters/docker/x86_64/Dockerfile index a7709e3a..f5c9476e 100644 --- a/clusters/docker/x86_64/Dockerfile +++ b/clusters/docker/x86_64/Dockerfile @@ -1,6 +1,6 @@ FROM gcr.io/distroless/static -COPY circonus-agentd / +ADD . /ca # NOTE: these are the default ports, use -p to map alternatives configured EXPOSE 2609/tcp EXPOSE 8125/udp -ENTRYPOINT ["/circonus-agentd"] \ No newline at end of file +ENTRYPOINT ["/ca/sbin/circonus-agentd"] \ No newline at end of file diff --git a/go.mod b/go.mod index 3d70c297..1c504b27 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 github.com/bi-zone/wmi v1.1.4 - github.com/circonus-labs/circonus-gometrics/v3 v3.4.6 + github.com/circonus-labs/circonus-gometrics/v3 v3.4.7 github.com/circonus-labs/go-apiclient v0.7.23 github.com/gojuno/minimock/v3 v3.1.3 github.com/google/uuid v1.4.0 @@ -15,11 +15,11 @@ require ( github.com/prometheus/client_model v0.5.0 github.com/prometheus/common v0.45.0 github.com/rs/zerolog v1.31.0 - github.com/shirou/gopsutil/v3 v3.23.9 - github.com/spf13/cobra v1.7.0 + github.com/shirou/gopsutil/v3 v3.23.10 + github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.17.0 - golang.org/x/sync v0.4.0 - golang.org/x/sys v0.13.0 + golang.org/x/sync v0.5.0 + golang.org/x/sys v0.14.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 28389faa..51be4086 100644 --- a/go.sum +++ b/go.sum @@ -813,8 +813,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonus-gometrics/v3 v3.4.6 h1:eSrULMsK5lm/tSCnZan1egARFWZ7U3rhKXeQwa4s9PQ= -github.com/circonus-labs/circonus-gometrics/v3 v3.4.6/go.mod h1:57gznrTyBxQCsGYC/+3BN9POyrkEm4F3KsBTVQ5EQJk= +github.com/circonus-labs/circonus-gometrics/v3 v3.4.7 h1:r7YBLIgiTT5Q4yNKSouP68M5mYT4djIQCng0dJdidiA= +github.com/circonus-labs/circonus-gometrics/v3 v3.4.7/go.mod h1:57gznrTyBxQCsGYC/+3BN9POyrkEm4F3KsBTVQ5EQJk= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/circonus-labs/go-apiclient v0.7.15/go.mod h1:RFgkvdYEkimzgu3V2vVYlS1bitjOz1SF6uw109ieNeY= github.com/circonus-labs/go-apiclient v0.7.23 h1:Bk+l9qLUHPGYND8z8Zxw3+d913ZIybD4CH1y5xSdtCk= @@ -838,7 +838,7 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH 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/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -971,8 +971,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -1277,8 +1278,8 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR github.com/scjalliance/comshim v0.0.0-20190308082608-cf06d2532c4e h1:+/AzLkOdIXEPrAQtwAeWOBnPQ0BnYlBW0aCZmSb47u4= github.com/scjalliance/comshim v0.0.0-20190308082608-cf06d2532c4e/go.mod h1:9Tc1SKnfACJb9N7cw2eyuI6xzy845G7uZONBsi5uPEA= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E= -github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA= +github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM= +github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE= 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= @@ -1297,8 +1298,8 @@ github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= -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/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= @@ -1582,8 +1583,8 @@ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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= @@ -1694,8 +1695,9 @@ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.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/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/internal/builtins/collector/prometheus/prometheus.go b/internal/builtins/collector/prometheus/prometheus.go index 142a1a6c..c8def155 100644 --- a/internal/builtins/collector/prometheus/prometheus.go +++ b/internal/builtins/collector/prometheus/prometheus.go @@ -40,21 +40,37 @@ type URLDef struct { // Prom defines prom collector. type Prom struct { - pkgID string // package prefix used for logging and errors - lastError string // last collection error - baseTags []string // base tags - urls []URLDef // prom URLs to collect metric from - lastEnd time.Time // last collection end time - lastMetrics cgm.Metrics // last metrics collected - lastStart time.Time // last collection start time - metricNameRegex *regexp.Regexp // OPT regex for cleaning names, may be overridden in config - logger zerolog.Logger // collector logging instance - lastRunDuration time.Duration // last collection duration - runTTL time.Duration // OPT ttl for collector (default is for every request) - running bool // is collector currently running + logger zerolog.Logger + lastEnd time.Time + lastStart time.Time + metricNameRegex *regexp.Regexp + lastMetrics cgm.Metrics + lastError string + pkgID string + urls []URLDef + baseTags []string + lastRunDuration time.Duration + runTTL time.Duration sync.Mutex + running bool } +// type Prom struct { +// pkgID string // package prefix used for logging and errors +// lastError string // last collection error +// baseTags []string // base tags +// urls []URLDef // prom URLs to collect metric from +// lastEnd time.Time // last collection end time +// lastMetrics cgm.Metrics // last metrics collected +// lastStart time.Time // last collection start time +// metricNameRegex *regexp.Regexp // OPT regex for cleaning names, may be overridden in config +// logger zerolog.Logger // collector logging instance +// lastRunDuration time.Duration // last collection duration +// runTTL time.Duration // OPT ttl for collector (default is for every request) +// running bool // is collector currently running +// sync.Mutex +// } + // promOptions defines what elements can be overridden in a config file. type promOptions struct { RunTTL string `json:"run_ttl" toml:"run_ttl" yaml:"run_ttl"` @@ -180,7 +196,7 @@ func (c *Prom) Collect(ctx context.Context) error { func (c *Prom) fetchPromMetrics(pctx context.Context, u URLDef, metrics *cgm.Metrics) error { req, err := http.NewRequest("GET", u.URL, nil) if err != nil { - return fmt.Errorf("prepare reqeust: %w", err) + return fmt.Errorf("prepare request: %w", err) } var ctx context.Context @@ -235,7 +251,7 @@ func (c *Prom) parse(id string, data io.Reader, metrics *cgm.Metrics) error { pfx := "" for mn, mf := range metricFamilies { - for _, m := range mf.Metric { + for _, m := range mf.GetMetric() { metricName := mn tags := c.getLabels(m) tags = append(tags, cgm.Tag{Category: "prom_id", Value: id}) @@ -253,21 +269,16 @@ func (c *Prom) parse(id string, data io.Reader, metrics *cgm.Metrics) error { _ = c.addMetric(metrics, pfx, metricName+"_"+bn, tags, "n", bv) } case dto.MetricType_COUNTER: - if m.GetCounter().Value != nil { - _ = c.addMetric(metrics, pfx, metricName, tags, "n", *m.GetCounter().Value) - } + _ = c.addMetric(metrics, pfx, metricName, tags, "n", m.GetCounter().GetValue()) case dto.MetricType_GAUGE: - if m.GetGauge().Value != nil { - _ = c.addMetric(metrics, pfx, metricName, tags, "n", *m.GetGauge().Value) - } + _ = c.addMetric(metrics, pfx, metricName, tags, "n", m.GetGauge().GetValue()) case dto.MetricType_UNTYPED: - if m.GetUntyped().Value != nil { - if *m.GetUntyped().Value == math.Inf(+1) { - c.logger.Warn().Str("metric", metricName).Str("type", mf.GetType().String()).Str("value", (*m).GetUntyped().String()).Msg("cannot coerce +Inf to uint64") - continue - } - _ = c.addMetric(metrics, pfx, metricName, tags, "n", *m.GetUntyped().Value) + v := m.GetUntyped().GetValue() + if v == math.Inf(+1) { + c.logger.Warn().Str("metric", metricName).Str("type", mf.GetType().String()).Str("value", (*m).GetUntyped().String()).Msg("cannot coerce +Inf to numeric") + continue } + _ = c.addMetric(metrics, pfx, metricName, tags, "n", mf) case dto.MetricType_GAUGE_HISTOGRAM: // not currently supported } @@ -281,10 +292,10 @@ func (c *Prom) getLabels(m *dto.Metric) tags.Tags { // Need to use cgm.Tags format and return a converted stream tags string labels := []string{} - for _, label := range m.Label { - if label.Name != nil && label.Value != nil { - ln := c.metricNameRegex.ReplaceAllString(*label.Name, "") - lv := c.metricNameRegex.ReplaceAllString(*label.Value, "") + for _, label := range m.GetLabel() { + if label.GetName() != "" && label.GetValue() != "" { + ln := c.metricNameRegex.ReplaceAllString(label.GetName(), "") + lv := c.metricNameRegex.ReplaceAllString(label.GetValue(), "") labels = append(labels, ln+tags.Delimiter+lv) // stream tags take form cat:val } } @@ -302,9 +313,10 @@ func (c *Prom) getLabels(m *dto.Metric) tags.Tags { func (c *Prom) getQuantiles(m *dto.Metric) map[string]float64 { ret := make(map[string]float64) - for _, q := range m.GetSummary().Quantile { - if q.Value != nil && !math.IsNaN(*q.Value) { - ret[fmt.Sprint(*q.Quantile)] = *q.Value + for _, q := range m.GetSummary().GetQuantile() { + v := q.GetValue() + if v != 0 && !math.IsNaN(v) { + ret[fmt.Sprint(q.GetQuantile())] = q.GetValue() } } return ret @@ -312,9 +324,9 @@ func (c *Prom) getQuantiles(m *dto.Metric) map[string]float64 { func (c *Prom) getBuckets(m *dto.Metric) map[string]uint64 { ret := make(map[string]uint64) - for _, b := range m.GetHistogram().Bucket { - if b.CumulativeCount != nil { - ret[fmt.Sprint(*b.UpperBound)] = *b.CumulativeCount + for _, b := range m.GetHistogram().GetBucket() { + if b.CumulativeCount != nil { //nolint:protogetter + ret[fmt.Sprint(*b.UpperBound)] = *b.CumulativeCount //nolint:protogetter } } return ret diff --git a/internal/check/api_test.go b/internal/check/api_test.go index 43c088c4..ebfc3104 100644 --- a/internal/check/api_test.go +++ b/internal/check/api_test.go @@ -40,11 +40,13 @@ func init() { panic(err) } - if data, err := os.ReadFile("testdata/ca.crt"); err != nil { + data, err := os.ReadFile("testdata/ca.crt") + if err != nil { panic(err) - } else { - cacert.Contents = string(data) } + + cacert.Contents = string(data) + } func genMockClient(mc *minimock.Controller) *APIMock { diff --git a/internal/check/bundle/api_test.go b/internal/check/bundle/api_test.go index 5b4680e6..203a67b2 100644 --- a/internal/check/bundle/api_test.go +++ b/internal/check/bundle/api_test.go @@ -44,11 +44,11 @@ func init() { panic(err) } - if data, err := os.ReadFile("testdata/ca.crt"); err != nil { + data, err := os.ReadFile("testdata/ca.crt") + if err != nil { panic(err) - } else { - cacert.Contents = string(data) } + cacert.Contents = string(data) } func genMockClient(mc *minimock.Controller) *APIMock { diff --git a/internal/check/check.go b/internal/check/check.go index 0ea33ae2..38f4b648 100644 --- a/internal/check/check.go +++ b/internal/check/check.go @@ -28,18 +28,18 @@ import ( // Check exposes the check bundle management interface. type Check struct { + logger zerolog.Logger + client API checkConfig *apiclient.Check checkBundle *bundle.Bundle broker *apiclient.Broker - statusActiveBroker string - client API revConfigs *ReverseConfigs - logger zerolog.Logger + statusActiveBroker string brokerMaxResponseTime time.Duration refreshTTL time.Duration brokerMaxRetries int - reverse bool sync.Mutex + reverse bool } // Meta contains check id meta data. @@ -259,7 +259,7 @@ func (c *Check) SubmissionURL() (string, *tls.Config, error) { return surl, tlsConfig, nil } -// CheckPeriod returns check bundle period (intetrval between when broker should make request). +// CheckPeriod returns check bundle period (interval between when broker should make request). func (c *Check) CheckPeriod() (uint, error) { c.Lock() defer c.Unlock() diff --git a/internal/multiagent/multiagent.go b/internal/multiagent/multiagent.go index d3dadda6..9252f3c2 100644 --- a/internal/multiagent/multiagent.go +++ b/internal/multiagent/multiagent.go @@ -45,17 +45,17 @@ type TrapResult struct { } type Submitter struct { + logger zerolog.Logger brokerTLSConfig *tls.Config client *http.Client svr *server.Server submissionURL string checkUUID string traceSubmits string - logger zerolog.Logger + interval time.Duration useCompression bool enabled bool accumulate bool - interval time.Duration } // submitLogshim is used to satisfy submission use of retryable-http Logger interface (avoiding ptr receiver issue). @@ -362,7 +362,7 @@ func (s *Submitter) getMetrics() Metrics { func (l submitLogshim) Printf(fmt string, v ...interface{}) { if strings.HasPrefix(fmt, "[DEBUG]") { - if e := l.logh.Debug(); !e.Enabled() { + if e := l.logh.Debug(); !e.Enabled() { //nolint:zerologlint return } } diff --git a/internal/reverse/reverse.go b/internal/reverse/reverse.go index 5c9e83e5..628a8f8e 100644 --- a/internal/reverse/reverse.go +++ b/internal/reverse/reverse.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "sync" - "time" "github.com/circonus-labs/circonus-agent/internal/check" "github.com/circonus-labs/circonus-agent/internal/config" @@ -21,10 +20,10 @@ import ( ) type Reverse struct { - agentAddress string + logger zerolog.Logger configs *check.ReverseConfigs chk *check.Check - logger zerolog.Logger + agentAddress string enabled bool } @@ -79,7 +78,6 @@ func (r *Reverse) Start(ctx context.Context) error { return fmt.Errorf("invalid reverse configurations (zero)") //nolint:goerr113 } - lastRefresh := time.Now() refreshCheck := false rctx, cancel := context.WithCancel(ctx) defer cancel() @@ -90,10 +88,6 @@ func (r *Reverse) Start(ctx context.Context) error { default: } - if time.Since(lastRefresh) > 5*time.Minute { - refreshCheck = true - } - if refreshCheck { r.logger.Debug().Msg("refreshing check") if err := r.chk.RefreshReverseConfig(); err != nil { @@ -119,11 +113,6 @@ func (r *Reverse) Start(ctx context.Context) error { refreshCheck = true continue } - // if nferr, ok := errors.Cause(err).(*check.ErrNoOwnerFound); ok { //nolint:errorlint - // r.logger.Warn().Err(nferr).Msg("refreshing check bundle configuration") - // refreshCheck = true - // continue - // } return fmt.Errorf("find primary broker: %w", err) } diff --git a/internal/server/promrecv/promrecv.go b/internal/server/promrecv/promrecv.go index 68dd8e60..80b0be51 100644 --- a/internal/server/promrecv/promrecv.go +++ b/internal/server/promrecv/promrecv.go @@ -66,7 +66,7 @@ func initCGM() error { metrics = hm - // inintialize any options for the receiver + // initialize any options for the receiver nameCleanerRx = regexp.MustCompile("[\r\n\"'`]") // used to strip unwanted characters baseTags = tags.GetBaseTags() @@ -101,7 +101,7 @@ func Parse(data io.Reader) error { } for mn, mf := range metricFamilies { - for _, m := range mf.Metric { + for _, m := range mf.GetMetric() { metricName := nameCleanerRx.ReplaceAllString(mn, "") tags := getLabels(m) switch { @@ -119,21 +119,21 @@ func Parse(data io.Reader) error { } default: switch { - case m.Gauge != nil: - if m.GetGauge().Value != nil { - metrics.GaugeWithTags(metricName, tags, *m.GetGauge().Value) + case m.GetGauge() != nil: + if m.GetGauge().Value != nil { //nolint:protogetter + metrics.GaugeWithTags(metricName, tags, *m.GetGauge().Value) //nolint:protogetter } - case m.Counter != nil: - if m.GetCounter().Value != nil { - metrics.GaugeWithTags(metricName, tags, *m.GetCounter().Value) + case m.GetCounter() != nil: + if m.GetCounter().Value != nil { //nolint:protogetter + metrics.GaugeWithTags(metricName, tags, *m.GetCounter().Value) //nolint:protogetter } - case m.Untyped != nil: - if m.GetUntyped().Value != nil { - if *m.GetUntyped().Value == math.Inf(+1) { + case m.GetUntyped() != nil: + if m.GetUntyped().Value != nil { //nolint:protogetter + if *m.GetUntyped().Value == math.Inf(+1) { //nolint:protogetter logger.Warn().Str("metric", metricName).Str("type", mf.GetType().String()).Str("value", (*m).GetUntyped().String()).Msg("cannot coerce +Inf to uint64") continue } - metrics.GaugeWithTags(metricName, tags, *m.GetUntyped().Value) + metrics.GaugeWithTags(metricName, tags, *m.GetUntyped().Value) //nolint:protogetter } } } @@ -144,11 +144,11 @@ func Parse(data io.Reader) error { } func getLabels(m *dto.Metric) tags.Tags { - labels := make([]string, 0, len(m.Label)) - for _, label := range m.Label { - if label.Name != nil && label.Value != nil { - ln := nameCleanerRx.ReplaceAllString(*label.Name, "") - lv := nameCleanerRx.ReplaceAllString(*label.Value, "") + labels := make([]string, 0, len(m.GetLabel())) + for _, label := range m.GetLabel() { + if label.GetName() != "" && label.GetValue() != "" { + ln := nameCleanerRx.ReplaceAllString(label.GetName(), "") + lv := nameCleanerRx.ReplaceAllString(label.GetValue(), "") labels = append(labels, ln+tags.Delimiter+lv) // stream tags take form cat:val } } @@ -166,9 +166,9 @@ func getLabels(m *dto.Metric) tags.Tags { func getQuantiles(m *dto.Metric) map[string]float64 { ret := make(map[string]float64) - for _, q := range m.GetSummary().Quantile { - if q.Value != nil && !math.IsNaN(*q.Value) { - ret[fmt.Sprint(*q.Quantile)] = *q.Value + for _, q := range m.GetSummary().GetQuantile() { + if q.Value != nil && !math.IsNaN(*q.Value) { //nolint:protogetter + ret[fmt.Sprint(*q.Quantile)] = *q.Value //nolint:protogetter } } return ret @@ -176,9 +176,9 @@ func getQuantiles(m *dto.Metric) map[string]float64 { func getBuckets(m *dto.Metric) map[string]uint64 { ret := make(map[string]uint64) - for _, b := range m.GetHistogram().Bucket { - if b.CumulativeCount != nil { - ret[fmt.Sprint(*b.UpperBound)] = *b.CumulativeCount + for _, b := range m.GetHistogram().GetBucket() { + if b.CumulativeCount != nil { //nolint:protogetter + ret[fmt.Sprint(*b.UpperBound)] = *b.CumulativeCount //nolint:protogetter } } return ret diff --git a/internal/statsd/statsd.go b/internal/statsd/statsd.go index 889b06f3..b787e511 100644 --- a/internal/statsd/statsd.go +++ b/internal/statsd/statsd.go @@ -32,6 +32,8 @@ import ( // Server defines a statsd server. type Server struct { + logger zerolog.Logger + groupCtx context.Context tcpConnections map[string]*net.TCPConn group *errgroup.Group udpAddress *net.UDPAddr @@ -42,32 +44,30 @@ type Server struct { nameSpaceReplaceRx *regexp.Regexp udpListener *net.UDPConn tcpListener *net.TCPListener - groupCtx context.Context - hostPrefix string - hostCategory string + apiKey string groupCID string groupPrefix string groupCounterOp string groupGaugeOp string groupSetOp string - apiKey string + hostCategory string apiApp string apiURL string apiCAFile string - metricRegexGroupNames []string + hostPrefix string baseTags []string - logger zerolog.Logger + metricRegexGroupNames []string tcpMaxConnections uint npp uint pqs uint - disabled bool - enableUDPListener bool // NOTE: defaults to TRUE; uses !disabled (not really a separate option) - enableTCPListener bool // NOTE: defaults to FALSE - debugCGM bool - debugMetricParsing bool groupMetricsmu sync.Mutex hostMetricsmu sync.Mutex sync.Mutex + disabled bool + enableUDPListener bool // NOTE: defaults to TRUE; uses !disabled (not really a separate option) + enableTCPListener bool // NOTE: defaults to FALSE + debugCGM bool + debugMetricParsing bool } const ( @@ -370,7 +370,7 @@ func (s *Server) initGroupMetrics() error { return nil } -// udpReader reads packets from the statsd udp listener, adds packets recevied to the queue. +// udpReader reads packets from the statsd udp listener, adds packets received to the queue. func (s *Server) udpReader(packetCh chan<- []byte) error { for { if s.done() { @@ -391,7 +391,7 @@ func (s *Server) udpReader(packetCh chan<- []byte) error { } } -// tcpHandler reads packets from the statsd tcp listener, adds packets recevied to the queue. +// tcpHandler reads packets from the statsd tcp listener, adds packets received to the queue. func (s *Server) tcpHandler(packetCh chan<- []byte) error { for { if s.done() { @@ -421,7 +421,7 @@ func (s *Server) tcpHandler(packetCh chan<- []byte) error { } } -// tcpReader reads packets from the statsd tcp listener, adds packets recevied to the queue. +// tcpReader reads packets from the statsd tcp listener, adds packets received to the queue. func (s *Server) tcpReader(conn *net.TCPConn, packetCh chan<- []byte) error { addr := conn.RemoteAddr().String() defer func() { diff --git a/macos_sign.sh b/macos_sign.sh new file mode 100755 index 00000000..db476287 --- /dev/null +++ b/macos_sign.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env zsh + +[ -n "$1" ] || { echo "invalid binary path"; exit 1; } +[ -n "$AC_APPID" ] || { echo "invalid AC_APPID"; exit 1; } + +xcrun codesign -s $AC_APPID -f -v --timestamp --options runtime $1