diff --git a/profiler/profiler.go b/profiler/profiler.go index df1a984022..d9b97efa96 100644 --- a/profiler/profiler.go +++ b/profiler/profiler.go @@ -21,7 +21,14 @@ const customProfileLabelLimit = 10 // It may return an error if an API key is not provided by means of the // WithAPIKey option, or if a hostname is not found. func Start(opts ...Option) error { - return v2.Start(opts...) + // HACK: quick fix for removing any nil options without releasing a new v2 version + var filteredOpts []Option + for _, opt := range opts { + if opt != nil { + filteredOpts = append(filteredOpts, opt) + } + } + return v2.Start(filteredOpts...) } // Stop cancels any ongoing profiling or upload operations and returns after diff --git a/profiler/profiler_test.go b/profiler/profiler_test.go index f8029ccd47..372ba2cfe9 100644 --- a/profiler/profiler_test.go +++ b/profiler/profiler_test.go @@ -637,3 +637,12 @@ func TestMetricsProfileStopEarlyNoLog(t *testing.T) { } } } + +func TestFilterNilOptionsOnStart(t *testing.T) { + // Test that nil options are filtered out when calling Start + // We set a nil option, because WithAPIKey was deprecated in v2, and + // we set also on purpose an option that will generate an error, as + // WithUploadTimeout(0) is not allowed. + err := Start(WithAPIKey("foo"), WithUploadTimeout(0)) + require.Error(t, err) +}