-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pyroscope/scrape): add support for configuring CPU profile's duration scraped by pyroscope.scrape
#591
Merged
tpaschalis
merged 11 commits into
grafana:main
from
hainenber:support-for-user-configuration-of-pyroscope-scrape-seconds-query-params
May 22, 2024
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4aefd9c
feat(pyroscope/scrape): add support for configuring CPU profile's dur…
hainenber 4e08a85
fix(ci): correct token identifier for Alloy marshaling
hainenber 7773517
Update pyroscope.scrape.md
hainenber e835d35
Update internal/component/pyroscope/scrape/scrape.go
hainenber 5304d84
feat(pyroscope/scrape): set `scrape_interval` as upper limit for `pro…
hainenber 777562f
chore(pyroscope/scrape): fix expected error's typo in unit test
hainenber fd9c97c
chore(pyroscope/scrape): configure proper configs for expected HTTPCl…
hainenber 581b887
feat(pyroscope/scrape): add support for configuring CPU profile's dur…
hainenber f3d89f6
feat(pyroscope/scrape): rename `profiling_duration` to more comprehen…
hainenber 0a35136
Merge branch 'main' into support-for-user-configuration-of-pyroscope-…
hainenber 771fcbd
Merge branch 'main' into support-for-user-configuration-of-pyroscope-…
tpaschalis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,15 +21,17 @@ import ( | |
) | ||
|
||
const ( | ||
pprofMemory string = "memory" | ||
pprofBlock string = "block" | ||
pprofGoroutine string = "goroutine" | ||
pprofMutex string = "mutex" | ||
pprofProcessCPU string = "process_cpu" | ||
pprofFgprof string = "fgprof" | ||
pprofGoDeltaProfMemory string = "godeltaprof_memory" | ||
pprofGoDeltaProfBlock string = "godeltaprof_block" | ||
pprofGoDeltaProfMutex string = "godeltaprof_mutex" | ||
pprofMemory string = "memory" | ||
pprofBlock string = "block" | ||
pprofGoroutine string = "goroutine" | ||
pprofMutex string = "mutex" | ||
pprofProcessCPU string = "process_cpu" | ||
pprofFgprof string = "fgprof" | ||
pprofGoDeltaProfMemory string = "godeltaprof_memory" | ||
pprofGoDeltaProfBlock string = "godeltaprof_block" | ||
pprofGoDeltaProfMutex string = "godeltaprof_mutex" | ||
defaultScrapeInterval time.Duration = 15 * time.Second | ||
defaultProfilingDuration time.Duration = defaultScrapeInterval - 1*time.Second | ||
) | ||
|
||
func init() { | ||
|
@@ -60,6 +62,8 @@ type Arguments struct { | |
ScrapeTimeout time.Duration `alloy:"scrape_timeout,attr,optional"` | ||
// The URL scheme with which to fetch metrics from targets. | ||
Scheme string `alloy:"scheme,attr,optional"` | ||
// The duration for a profile to be scrapped. | ||
ProfilingDuration time.Duration `alloy:"profiling_duration,attr,optional"` | ||
|
||
// todo(ctovena): add support for limits. | ||
// // An uncompressed response body larger than this many bytes will cause the | ||
|
@@ -192,11 +196,12 @@ var DefaultArguments = NewDefaultArguments() | |
// NewDefaultArguments create the default settings for a scrape job. | ||
func NewDefaultArguments() Arguments { | ||
return Arguments{ | ||
Scheme: "http", | ||
HTTPClientConfig: component_config.DefaultHTTPClientConfig, | ||
ScrapeInterval: 15 * time.Second, | ||
ScrapeTimeout: 10 * time.Second, | ||
ProfilingConfig: DefaultProfilingConfig, | ||
Scheme: "http", | ||
HTTPClientConfig: component_config.DefaultHTTPClientConfig, | ||
ScrapeInterval: 15 * time.Second, | ||
ScrapeTimeout: 10 * time.Second, | ||
ProfilingConfig: DefaultProfilingConfig, | ||
ProfilingDuration: defaultProfilingDuration, | ||
} | ||
} | ||
|
||
|
@@ -218,6 +223,14 @@ func (arg *Arguments) Validate() error { | |
if target.Enabled && target.Delta && arg.ScrapeInterval.Seconds() < 2 { | ||
return fmt.Errorf("scrape_interval must be at least 2 seconds when using delta profiling") | ||
} | ||
if target.Enabled && target.Delta { | ||
if arg.ProfilingDuration.Seconds() <= 1 { | ||
return fmt.Errorf("profiling_duration must be larger than 1 second when using delta profiling") | ||
} | ||
if arg.ProfilingDuration.Seconds() >= arg.ScrapeInterval.Seconds() { | ||
return fmt.Errorf("profiling_duration must be smaller than scrape_interval when using delta profiling") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this condition make sure that DeltaProfilingDuration is not only smaller, but also at least a second smaller? |
||
} | ||
} | ||
|
||
// We must explicitly Validate because HTTPClientConfig is squashed and it won't run otherwise | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one last thing. Could we name this with a little more descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this in HEAD. PTAL