Skip to content

Commit fa0d157

Browse files
committed
resolving merge conflict
2 parents f25ca7e + 9c552a3 commit fa0d157

Some content is hidden

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

41 files changed

+1310
-364
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
with:
5151
go-version-file: 'go.mod'
5252
cache: false
53-
- name: run install-tools
54-
run: make install-tools
55-
- name: run lint
56-
run: make lint
53+
- name: Lint Go
54+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
55+
with:
56+
version: v2.4.0
5757

5858
unit-test:
5959
name: Unit Tests

.github/workflows/release-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ on:
4242

4343
env:
4444
NFPM_VERSION: 'v2.35.3'
45-
GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-dev"
45+
GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-local-approved-dependency"
4646

4747
defaults:
4848
run:

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ linters:
122122
- G110
123123
- G111
124124
- G112
125-
- G113
126125
- G114
127126
- G201
128127
- G202

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ build: ## Build agent executable
125125

126126
lint: ## Run linter
127127
@$(GOVET) ./...
128+
@$(GORUN) $(GOLANGCILINT) config verify -c ./.golangci.yml
128129
@$(GORUN) $(GOLANGCILINT) run -c ./.golangci.yml
129130
@cd api/grpc && $(GORUN) $(BUF) generate
130131
@echo "🏯 Linting Done"

Makefile.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OAPICODEGEN = github.com/deepmap/oapi-codegen/v2/cmd/[email protected]
22
LEFTHOOK = github.com/evilmartians/[email protected]
3-
GOLANGCILINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1
3+
GOLANGCILINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
44
PROTOCGENGO = google.golang.org/protobuf/cmd/[email protected]
55
GOFUMPT = mvdan.cc/[email protected]
66
COUNTERFEITER = github.com/maxbrunsfeld/counterfeiter/[email protected]

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/nginx/agent/v3
22

33
go 1.24.0
44

5-
toolchain go1.24.4
5+
toolchain go1.24.6
66

77
require (
88
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-20250130201111-63bb56e20495.1

internal/collector/containermetricsreceiver/internal/scraper/cpuscraper/internal/cgroup/cpu.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cgroup
77

88
import (
99
"bytes"
10+
"context"
1011
"errors"
1112
"os/exec"
1213
"path"
@@ -63,17 +64,17 @@ func NewCPUSource(basePath string) *CPUSource {
6364
}
6465
}
6566

66-
func (cs *CPUSource) Collect() (ContainerCPUStats, error) {
67-
cpuStats, err := cs.collectCPUStats()
67+
func (cs *CPUSource) Collect(ctx context.Context) (ContainerCPUStats, error) {
68+
cpuStats, err := cs.collectCPUStats(ctx)
6869
if err != nil {
6970
return ContainerCPUStats{}, err
7071
}
7172

7273
return cpuStats, nil
7374
}
7475

75-
func (cs *CPUSource) collectCPUStats() (ContainerCPUStats, error) {
76-
clockTicks, err := clockTicks()
76+
func (cs *CPUSource) collectCPUStats(ctx context.Context) (ContainerCPUStats, error) {
77+
clockTicks, err := clockTicks(ctx)
7778
const nanosecondsPerMillisecond = 1000
7879
if err != nil {
7980
return ContainerCPUStats{}, err
@@ -190,8 +191,8 @@ func systemCPUUsage(clockTicks int) (float64, error) {
190191
return 0, errors.New("unable to process " + CPUStatsPath + ". No cpu found")
191192
}
192193

193-
func clockTicks() (int, error) {
194-
cmd := exec.Command("getconf", "CLK_TCK")
194+
func clockTicks(ctx context.Context) (int, error) {
195+
cmd := exec.CommandContext(ctx, "getconf", "CLK_TCK")
195196
out := new(bytes.Buffer)
196197
cmd.Stdout = out
197198

internal/collector/containermetricsreceiver/internal/scraper/cpuscraper/internal/cgroup/cpu_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package cgroup
77

88
import (
9+
"context"
910
"os"
1011
"path"
1112
"runtime"
@@ -19,6 +20,8 @@ func TestCollectCPUStats(t *testing.T) {
1920
_, filename, _, _ := runtime.Caller(0)
2021
localDirectory := path.Dir(filename)
2122

23+
ctx := context.Background()
24+
2225
tests := []struct {
2326
errorType error
2427
name string
@@ -73,7 +76,7 @@ func TestCollectCPUStats(t *testing.T) {
7376
for _, test := range tests {
7477
t.Run(test.name, func(tt *testing.T) {
7578
cgroupCPUSource := NewCPUSource(test.basePath)
76-
cpuStat, err := cgroupCPUSource.collectCPUStats()
79+
cpuStat, err := cgroupCPUSource.collectCPUStats(ctx)
7780

7881
// Assert error
7982
assert.IsType(tt, test.errorType, err)

internal/collector/containermetricsreceiver/internal/scraper/cpuscraper/scraper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ func (s *CPUScraper) Start(_ context.Context, _ component.Host) error {
5757
return nil
5858
}
5959

60-
func (s *CPUScraper) Scrape(context.Context) (pmetric.Metrics, error) {
60+
func (s *CPUScraper) Scrape(ctx context.Context) (pmetric.Metrics, error) {
6161
s.settings.Logger.Debug("Scraping container CPU metrics")
6262

6363
now := pcommon.NewTimestampFromTime(time.Now())
6464

65-
stats, err := s.cpuSource.Collect()
65+
stats, err := s.cpuSource.Collect(ctx)
6666
if err != nil {
6767
return pmetric.NewMetrics(), err
6868
}

internal/collector/nginxossreceiver/internal/scraper/stubstatus/stub_status_scraper.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *NginxStubStatusScraper) ID() component.ID {
6262
return component.NewID(metadata.Type)
6363
}
6464

65-
//nolint:unparam // // Result is always nil
65+
//nolint:unparam // Result is always nil
6666
func (s *NginxStubStatusScraper) Start(_ context.Context, _ component.Host) error {
6767
s.logger.Info("Starting NGINX stub status scraper")
6868
httpClient := http.DefaultClient
@@ -92,8 +92,9 @@ func (s *NginxStubStatusScraper) Start(_ context.Context, _ component.Host) erro
9292

9393
if strings.HasPrefix(s.cfg.APIDetails.Listen, "unix:") {
9494
httpClient.Transport = &http.Transport{
95-
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
96-
return net.Dial("unix", strings.TrimPrefix(s.cfg.APIDetails.Listen, "unix:"))
95+
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
96+
dialer := &net.Dialer{}
97+
return dialer.DialContext(ctx, "unix", strings.TrimPrefix(s.cfg.APIDetails.Listen, "unix:"))
9798
},
9899
}
99100
}

0 commit comments

Comments
 (0)