Skip to content

Commit

Permalink
add cli flags
Browse files Browse the repository at this point in the history
  • Loading branch information
umanwizard committed Nov 26, 2024
1 parent c3f4152 commit 5cced87
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
9 changes: 9 additions & 0 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ type Flags struct {
RubyUnwindingDisable bool `default:"false" help:"[deprecated] Disable Ruby unwinder."`
JavaUnwindingDisable bool `default:"true" help:"[deprecated] Disable Java unwinder."`

// which metrics producers (e.g. nvidia) to enable
MetricsProducer FlagsMetricProducer `embed:"" prefix:"metrics-producer-"`

CollectCustomLabels bool `default:"false" help:"Attempt to collect custom labels (e.g. trace ID) from the process."`

AnalyticsOptOut bool `default:"false" help:"Opt out of sending anonymous usage statistics."`
Expand Down Expand Up @@ -311,6 +314,12 @@ type FlagsDWARFUnwinding struct {
Mixed bool `default:"true" help:"[deprecated] Unwind using .eh_frame information and frame pointers."`
}

// FlagsMetricProducer contains flags that configure arrow metrics production.
type FlagsMetricProducer struct {
NvidiaGpu bool `default:"false" help:"Collect metrics related to Nvidia GPUs."`
NvidiaGpuMock bool `default:"false" help:"Generate fake Nvidia GPU metrics." hidden:""`
}

type FlagsTelemetry struct {
DisablePanicReporting bool `default:"false"`
StderrBufferSizeKb int64 `default:"4096"`
Expand Down
33 changes: 23 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,30 @@ func mainWithExitCode() flags.ExitCode {

arrowClient := arrowpb.NewArrowMetricsServiceClient(grpcConn)
arrowMetricsExporter := arrowmetrics.NewExporter(arrowClient, time.Second*10, map[string]any{"foo": "bar"})
// nvidia, err := arrowmetrics.NewNvidiaProducer()
nvidia := arrowmetrics.NewNvidiaMockProducer(3, time.Now())
err = nil
if err != nil {
// XXX
panic(err)
const nvidiaMetricsScopeName = "parca.nvidia_gpu_metrics"
if f.MetricsProducer.NvidiaGpu {
nvidia, err := arrowmetrics.NewNvidiaProducer()
if err != nil {
return flags.Failure("Failed to instantiate nvidia metrics producer: %v. Are the Nvidia drivers installed?", err)
}
arrowMetricsExporter.AddProducer(arrowmetrics.ProducerConfig{
Producer: nvidia,
ScopeName: nvidiaMetricsScopeName,
})
}
if f.MetricsProducer.NvidiaGpuMock {
mock := arrowmetrics.NewNvidiaMockProducer(3, time.Now())
scopeName := nvidiaMetricsScopeName
if f.MetricsProducer.NvidiaGpu {
// don't conflict with the real producer
scopeName = scopeName + "_mock"
}
arrowMetricsExporter.AddProducer(arrowmetrics.ProducerConfig{
Producer: mock,
ScopeName: scopeName,
})

}
arrowMetricsExporter.AddProducer(arrowmetrics.ProducerConfig{
Producer: nvidia,
ScopeName: "parca.nvidia_gpu_metrics",
})
arrowMetricsExporter.Start(ctx)

// Network operations to CA start here
Expand Down

0 comments on commit 5cced87

Please sign in to comment.