Skip to content

Commit 1c6db00

Browse files
authored
OffCPU flag (#3037)
* OffCPU flags * Update go.mod
1 parent 7d5f5cc commit 1c6db00

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

flags/flags.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/alecthomas/kong"
2525
log "github.com/sirupsen/logrus"
26+
"go.opentelemetry.io/ebpf-profiler/support"
2627
"go.opentelemetry.io/ebpf-profiler/tracer"
2728
_ "google.golang.org/grpc/encoding/proto"
2829
)
@@ -122,7 +123,8 @@ type Flags struct {
122123

123124
BPF FlagsBPF `embed:"" prefix:"bpf-"`
124125

125-
OfflineMode FlagsOfflineMode `embed:"" prefix:"offline-mode-"`
126+
OfflineMode FlagsOfflineMode `embed:"" prefix:"offline-mode-"`
127+
OffCPUThreshold uint `default:"0" help:"The per-mille probablity of off-CPU event being recorded."`
126128
}
127129

128130
type ExitCode int
@@ -202,6 +204,11 @@ func (f Flags) Validate() ExitCode {
202204
return ParseError("Specified --offline-mode-upload without --offline-mode-storage-path.")
203205
}
204206

207+
if f.OffCPUThreshold > support.OffCPUThresholdMax {
208+
return ParseError("Off-CPU threshold %d exceeds limit (max: %d)",
209+
f.OffCPUThreshold, support.OffCPUThresholdMax)
210+
}
211+
205212
return ExitSuccess
206213
}
207214

@@ -355,7 +362,7 @@ type FlagsBPF struct {
355362
}
356363

357364
type FlagsOfflineMode struct {
358-
StoragePath string `help:"Enables offline mode, with the data stored at the given path."`
359-
RotationInterval time.Duration `default:"10m" help:"How often to rotate and compress the offline mode log."`
360-
Upload bool `help:"Run the uploader for data written in offline mode."`
365+
StoragePath string `help:"Enables offline mode, with the data stored at the given path."`
366+
RotationInterval time.Duration `default:"10m" help:"How often to rotate and compress the offline mode log."`
367+
Upload bool `help:"Run the uploader for data written in offline mode."`
361368
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,4 @@ require (
153153
sigs.k8s.io/yaml v1.3.0 // indirect
154154
)
155155

156-
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250306230038-78e858b85337
156+
replace go.opentelemetry.io/ebpf-profiler => github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250311092013-ec1cdb3482af

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bl
258258
github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
259259
github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU=
260260
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
261-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250306230038-78e858b85337 h1:qJ3p+TmnDFPAX+XhBSHpgnETRofp8Yn6FzOBfwxKzyc=
262-
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250306230038-78e858b85337/go.mod h1:q15sN2PgXSh337bNjdeUz4WCIlqQrO/Nx0H5O7o5WiI=
261+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250311092013-ec1cdb3482af h1:2MhE8xUeyjPux1INz/40WEt7raxzUNMiRfGSNIb7gc0=
262+
github.com/parca-dev/opentelemetry-ebpf-profiler v0.0.0-20250311092013-ec1cdb3482af/go.mod h1:q15sN2PgXSh337bNjdeUz4WCIlqQrO/Nx0H5O7o5WiI=
263263
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
264264
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
265265
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ func mainWithExitCode() flags.ExitCode {
361361
ProbabilisticInterval: f.Profiling.ProbabilisticInterval,
362362
ProbabilisticThreshold: f.Profiling.ProbabilisticThreshold,
363363
CollectCustomLabels: f.CollectCustomLabels,
364+
OffCPUThreshold: uint32(f.OffCPUThreshold),
364365
})
365366
if err != nil {
366367
return flags.Failure("Failed to load eBPF tracer: %v", err)

0 commit comments

Comments
 (0)