-
Notifications
You must be signed in to change notification settings - Fork 208
PMM-12832 Add exporter connection timeout to DSN/config based exporters. #5275
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
base: v3
Are you sure you want to change the base?
Changes from 9 commits
abe8a73
cab99a2
071e3df
deda319
988cdba
5a7102d
ff7ff95
6840b4b
5e15937
d858d5a
2879d98
3e0f98f
9bccfce
c0b715b
df2eb20
2521c82
f6609df
ca21749
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright (C) 2023 Percona LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package commands | ||
|
|
||
| import ( | ||
| "strconv" | ||
| "time" | ||
| ) | ||
|
|
||
| // DurationString returns the string representation of a duration flag. | ||
| func DurationString(value *time.Duration) string { | ||
| if value == nil { | ||
| return "" | ||
| } | ||
|
|
||
| return strconv.FormatFloat(value.Seconds(), 'f', -1, 64) + "s" | ||
| } | ||
|
Comment on lines
+23
to
+29
Contributor
Author
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. Fix for #5134 (comment) |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Copyright (C) 2023 Percona LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package commands | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestDurationString(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| t.Run("nil", func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| assert.Equal(t, "", DurationString(nil)) | ||
| }) | ||
|
|
||
| for _, testCase := range []struct { | ||
| name string | ||
| value time.Duration | ||
| expected string | ||
| }{ | ||
| { | ||
| name: "sub-second", | ||
| value: 500 * time.Millisecond, | ||
| expected: "0.5s", | ||
| }, | ||
| { | ||
| name: "multi-minute", | ||
| value: 90 * time.Second, | ||
| expected: "90s", | ||
| }, | ||
| { | ||
| name: "hour", | ||
| value: time.Hour, | ||
| expected: "3600s", | ||
| }, | ||
| } { | ||
| t.Run(testCase.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| assert.Equal(t, testCase.expected, DurationString(&testCase.value)) | ||
| }) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ package inventory | |
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/percona/pmm/admin/commands" | ||
| "github.com/percona/pmm/admin/pkg/flags" | ||
|
|
@@ -89,9 +90,10 @@ type ChangeAgentMongodbExporterCommand struct { | |
| CollectionsLimit *int32 `help:"Collections limit"` | ||
|
|
||
| // Exporter options | ||
| DisableCollectors []string `help:"List of collector names to disable"` | ||
| ExposeExporter *bool `help:"Expose the exporter process on all public interfaces"` | ||
| PushMetrics *bool `help:"Enable push metrics with vmagent"` | ||
| DisableCollectors []string `help:"List of collector names to disable"` | ||
| ExposeExporter *bool `help:"Expose the exporter process on all public interfaces"` | ||
| PushMetrics *bool `help:"Enable push metrics with vmagent"` | ||
| ConnectionTimeout *time.Duration `placeholder:"DURATION" help:"Connection timeout to use for exporter (e.g. 1s, 1.5s)"` | ||
|
|
||
| // Custom labels | ||
| CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"` | ||
|
|
@@ -152,6 +154,7 @@ func (cmd *ChangeAgentMongodbExporterCommand) RunCmd() (commands.Result, error) | |
| ExposeExporter: cmd.ExposeExporter, | ||
| EnablePushMetrics: cmd.PushMetrics, | ||
| LogLevel: convertLogLevelPtr(cmd.LogLevel), | ||
| ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout), | ||
|
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. Change commands may unintentionally clear connection timeoutMedium Severity
Additional Locations (2)Reviewed by Cursor Bugbot for commit ca21749. Configure here. |
||
| } | ||
|
|
||
| if customLabels != nil { | ||
|
|
||


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.
Linter issue from original PR, there and in admin commands.