Skip to content

Commit d5f5904

Browse files
committed
OffCPU flags
1 parent 7d5f5cc commit d5f5904

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
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
}

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)