Skip to content

Commit

Permalink
Fix various lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandem committed Aug 30, 2024
1 parent b5da141 commit 70616de
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (e EnvironmentType) String() string {
case envAzure:
return "azure"
case envAWS:
// nolint: goconst
//nolint: goconst
return "aws"
default:
return fmt.Sprintf("unknown environment %d", e)
Expand Down
2 changes: 1 addition & 1 deletion containermetadata/containermetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func BenchmarkGetKubernetesPodMetadata(b *testing.B) {

file, err := os.CreateTemp("", "test_containermetadata_cgroup*")
require.NoError(b, err)
defer os.Remove(file.Name()) // nolint: gocritic
defer os.Remove(file.Name()) //nolint: gocritic

_, err = fmt.Fprintf(file,
"0::/kubepods/besteffort/poda9c80282-3f6b-4d5b-84d5-a137a6668011/"+
Expand Down
3 changes: 1 addition & 2 deletions hostmetadata/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ type IMDS struct {
// Failures (missing keys, etc) are logged and ignored.
//
// We extract the Azure metadata according to the information at
// nolint:lll
// https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=linux#endpoint-categories
// https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=linux#endpoint-categories //nolint:lll
//
// - 169.254.169.254 is the standard endpoint for the instance metadata service in all clouds.
// One of the few things all cloud providers agree upon
Expand Down
2 changes: 1 addition & 1 deletion hostmetadata/azure/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/require"
)

// nolint:lll
//nolint:lll
const fakeAzureAnswer = `{
"compute": {
"azEnvironment": "AzurePublicCloud",
Expand Down
1 change: 1 addition & 0 deletions hostmetadata/host/cpuid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestCPUID_ParseOnlineCPUCoreIDs(t *testing.T) {
func prepareFakeCPUOnlineFile(t *testing.T, content string) *os.File {
f, err := os.CreateTemp("", "sys_device_cpu_online")
require.NoError(t, err)
//nolint:gosec
_ = os.WriteFile(f.Name(), []byte(content), os.ModePerm)
return f
}
2 changes: 1 addition & 1 deletion hostmetadata/host/cpuinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestReadCPUInfo(t *testing.T) {
assert.NotEmpty(t, cps)
i, err := strconv.Atoi(cps)
require.NoErrorf(t, err, "%v must be parseable as a number", cps)
assert.Greater(t, i, 0)
assert.Positive(t, i)
},
"OnlineCPUs": func(t *testing.T) {
assert.Contains(t, info[key(keyCPUOnline)], 0)
Expand Down
2 changes: 1 addition & 1 deletion libpf/pfelf/pfelf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestGetGoBuildID(t *testing.T) {
t.Fatalf("GetGoBuildID failed with error: %s", err)
}

// nolint:lll
//nolint:lll

Check failure on line 60 in libpf/pfelf/pfelf_test.go

View workflow job for this annotation

GitHub Actions / Lint (stable)

directive `//nolint:lll` is unused for linter "lll" (nolintlint)
if buildID !=
"tUhrGOwxi48kXlLhYlY3/WlmPekR2qonrFvofssLt/8beXJbt0rDaHhn3I6x8D/IA6Zd8Qc8Rsh_bFKoPVn" {
t.Fatalf("Invalid build-id: %s", buildID)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func mainWithExitCode() exitCode {
}

if err = tracer.ProbeBPFSyscall(); err != nil {
log.Errorf(fmt.Sprintf("Failed to probe eBPF syscall: %v", err))
log.Errorf("Failed to probe eBPF syscall: %v", err)
return exitFailure
}

Expand Down
6 changes: 3 additions & 3 deletions metrics/cpumetrics/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ func getCPUUsage() (pAvgCPU uint16, err error) {
// Calculate the maximum possible value for the elapsed time (duration).
// nCPUs*userHZ: The max. number of ticks per second.
// duration / time.Second: Time elapsed in seconds.
max := float64(nCPUs*userHZ) * (float64(duration) / float64(time.Second))
maximum := float64(nCPUs*userHZ) * (float64(duration) / float64(time.Second))

// Calculate the % value of the CPU usage with rounding.
if max > 0 {
pAvgCPU = uint16(float64(load*100)/max + 0.5)
if maximum > 0 {
pAvgCPU = uint16(float64(load*100)/maximum + 0.5)
if pAvgCPU > 100 {
pAvgCPU = 100
}
Expand Down
1 change: 1 addition & 0 deletions reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ func createPprofFunctionEntry(funcMap map[funcInfo]*pprofile.Function,
return function
}

//nolint:gocritic
func addTraceLabels(labels map[string][]string, k traceAndMetaKey) {
if k.comm != "" {
labels["thread_name"] = append(labels["thread_name"], k.comm)
Expand Down
4 changes: 2 additions & 2 deletions reporter/datadog_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func uploadProfiles(ctx context.Context, profiles []profileData, startTime, endT
return err
}
req.Header.Set("Content-Type", contentType)
req.Header.Set("DD-EVP-ORIGIN", profilerName)
req.Header.Set("DD-EVP-ORIGIN-VERSION", vc.Version())
req.Header.Set("Dd-Evp-Origin", profilerName)
req.Header.Set("Dd-Evp-Origin-Version", vc.Version())

// If you're uploading directly to our intake, add the API key here:
// req.Header.Set("DD-API-KEY", "xxxx")
Expand Down
2 changes: 2 additions & 0 deletions reporter/otlp_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ func createFunctionEntry(funcMap map[funcInfo]uint64,
}

// getSampleAttributes builds a sample-specific list of attributes.
//
//nolint:gocritic
func getSampleAttributes(profile *profiles.Profile, k traceAndMetaKey) []uint64 {
indices := make([]uint64, 0, 4)

Expand Down
6 changes: 3 additions & 3 deletions symbolication/datadog_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ func (d *DatadogUploader) buildSymbolUploadRequest(symbolFile *os.File,
return nil, fmt.Errorf("failed to create request: %w", err)
}

r.Header.Set("DD-API-KEY", d.ddAPIKey)
r.Header.Set("DD-EVP-ORIGIN", "otel-profiling-agent")
r.Header.Set("DD-EVP-ORIGIN-VERSION", vc.Version())
r.Header.Set("Dd-Api-Key", d.ddAPIKey)
r.Header.Set("Dd-Evp-Origin", "otel-profiling-agent")
r.Header.Set("Dd-Evp-Origin-Version", vc.Version())
r.Header.Set("Content-Type", mw.FormDataContentType())
r.Header.Set("Content-Encoding", "gzip")
return r, nil
Expand Down

0 comments on commit 70616de

Please sign in to comment.