-
Notifications
You must be signed in to change notification settings - Fork 814
feat(reexecute/c): explicit metrics port #4418
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
Open
RodrigoVillar
wants to merge
34
commits into
master
Choose a base branch
from
rodrigo/support-explicit-metrics-port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+34
−12
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
0178776
feat(reexecution/c): decouple metrics server and collector
RodrigoVillar 4ad3f2b
Merge branch 'master' into rodrigo/decouple-reexecution-metrics
RodrigoVillar fc83c89
Merge branch 'master' into rodrigo/decouple-reexecution-metrics
RodrigoVillar 848c6ad
docs: improve collectRegistry
RodrigoVillar be761ac
chore: set default to empty string
RodrigoVillar ca0b993
docs: benchmark script
RodrigoVillar a7cb056
chore: simplify metricsMode
RodrigoVillar d36d4ca
Merge branch 'master' into rodrigo/decouple-reexecution-metrics
RodrigoVillar c7f3185
chore: unexport metricsMode
RodrigoVillar 9e319d0
chore: clean up
RodrigoVillar 2cc0a79
chore: self-review nits
RodrigoVillar feb1681
feat(reexecute/c): explicit metrics port
RodrigoVillar c7c83bb
Merge branch 'master' into rodrigo/support-explicit-metrics-port
RodrigoVillar a5d4392
chore: nits
RodrigoVillar 4ff8126
Merge branch 'master' into rodrigo/support-explicit-metrics-port
RodrigoVillar c67da7f
chore: nits
RodrigoVillar f5e2e14
chore: unexport consts
RodrigoVillar d871c75
chore: README
RodrigoVillar 540d60f
chore: nit
RodrigoVillar bca6d48
chore: nit
RodrigoVillar e381c2c
Merge branch 'master' into rodrigo/support-explicit-metrics-port
RodrigoVillar e5283df
Merge branch 'master' into rodrigo/support-explicit-metrics-port
RodrigoVillar ac02cbf
docs: func name
RodrigoVillar 4654206
chore: unify server flags
RodrigoVillar d18bbb8
chore: nit
RodrigoVillar df721f1
fix: quote
RodrigoVillar 527b652
feat: implicitly enable metrics server if collector is enabled
RodrigoVillar f2fc794
chore: nits
RodrigoVillar f156a76
docs: README
RodrigoVillar 5bb04be
chore: nit
RodrigoVillar d0b0083
docs: flag usage
RodrigoVillar 6796474
Merge branch 'master' into rodrigo/support-explicit-metrics-port
RodrigoVillar 830e8c1
chore: nits
RodrigoVillar 3651f47
chore: revert unification of metrics server param
RodrigoVillar 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ var ( | |
| labelsArg string | ||
|
|
||
| metricsServerEnabledArg bool | ||
| metricsServerPortArg uint64 | ||
| metricsCollectorEnabledArg bool | ||
|
|
||
| networkUUID string = uuid.NewString() | ||
|
|
@@ -105,6 +106,7 @@ func TestMain(m *testing.M) { | |
| flag.DurationVar(&executionTimeout, "execution-timeout", 0, "Benchmark execution timeout. After this timeout has elapsed, terminate the benchmark without error. If 0, no timeout is applied.") | ||
|
|
||
| flag.BoolVar(&metricsServerEnabledArg, "metrics-server-enabled", false, "Whether to enable the metrics server.") | ||
| flag.Uint64Var(&metricsServerPortArg, "metrics-server-port", 0, "The port the metrics server will listen to.") | ||
|
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. Given that that port numbers are 16 bit, is there a reason to prefer 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. Yes, |
||
| flag.BoolVar(&metricsCollectorEnabledArg, "metrics-collector-enabled", false, "Whether to enable the metrics collector (if true, then metrics-server-enabled must be true as well).") | ||
| flag.StringVar(&labelsArg, "labels", "", "Comma separated KV list of metric labels to attach to all exported metrics. Ex. \"owner=tim,runner=snoopy\"") | ||
|
|
||
|
|
@@ -119,9 +121,8 @@ func TestMain(m *testing.M) { | |
|
|
||
| flag.Parse() | ||
|
|
||
| if metricsCollectorEnabledArg && !metricsServerEnabledArg { | ||
| fmt.Fprint(os.Stderr, "metrics collector is enabled but metrics server is disabled.\n") | ||
| os.Exit(1) | ||
| if metricsCollectorEnabledArg { | ||
| metricsServerEnabledArg = true | ||
| } | ||
|
|
||
| customLabels, err := parseCustomLabels(labelsArg) | ||
|
|
@@ -158,6 +159,7 @@ func BenchmarkReexecuteRange(b *testing.B) { | |
| endBlockArg, | ||
| chanSizeArg, | ||
| metricsServerEnabledArg, | ||
| metricsServerPortArg, | ||
| metricsCollectorEnabledArg, | ||
| ) | ||
| }) | ||
|
|
@@ -172,6 +174,7 @@ func benchmarkReexecuteRange( | |
| endBlock uint64, | ||
| chanSize int, | ||
| metricsServerEnabled bool, | ||
| metricsPort uint64, | ||
| metricsCollectorEnabled bool, | ||
| ) { | ||
| r := require.New(b) | ||
|
|
@@ -192,7 +195,7 @@ func benchmarkReexecuteRange( | |
| log := tests.NewDefaultLogger("c-chain-reexecution") | ||
|
|
||
| if metricsServerEnabled { | ||
| serverAddr := startServer(b, log, prefixGatherer) | ||
| serverAddr := startServer(b, log, prefixGatherer, metricsPort) | ||
|
|
||
| if metricsCollectorEnabled { | ||
| startCollector(b, log, "c-chain-reexecution", labels, serverAddr) | ||
|
|
@@ -565,10 +568,11 @@ func startServer( | |
| tb testing.TB, | ||
| log logging.Logger, | ||
| gatherer prometheus.Gatherer, | ||
| port uint64, | ||
| ) string { | ||
| r := require.New(tb) | ||
|
|
||
| server, err := tests.NewPrometheusServer(gatherer) | ||
| server, err := tests.NewPrometheusServerWithPort(gatherer, port) | ||
| r.NoError(err) | ||
|
|
||
| log.Info("metrics endpoint available", | ||
|
|
||
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.
I would like to see
METRICS_SERVER_PORTbe in addition toMETRICS_SERVER_ENABLEDrather than its replacement. The default port should remain zero - dynamic - and that detail shouldn't be required knowledge for those who don't want to set a specific port.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.
Done: 3651f47
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.
Why the preference to make this in addition instead of a single flag @maru-ava ?
Made an opposite comment here #4418 (comment)
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.
The rule of thumb here is 'Separate the Decision from the Details/Decouple Orthogonal Concerns': If two aspects of configuration answer different questions, they should be separate controls. Whether metrics export is enabled is a separable concern from configuring the port used for export. While conflating them seems like a reasonable simplification, best practice is to keep them separate for clarity and composability.