Skip to content

PMM-12832 Add exporter connection timeout to DSN/config based exporters.#5275

Open
JiriCtvrtka wants to merge 18 commits intov3from
PMM-12832-connection-timeout
Open

PMM-12832 Add exporter connection timeout to DSN/config based exporters.#5275
JiriCtvrtka wants to merge 18 commits intov3from
PMM-12832-connection-timeout

Conversation

@JiriCtvrtka
Copy link
Copy Markdown
Contributor

@JiriCtvrtka JiriCtvrtka commented Apr 21, 2026

PMM-12832

FB: Percona-Lab/pmm-submodules#4310

New separated PR for connection timeouts for exporters based on DSN/config.

Support connection timeout configuration for DB-backed exporters where the timeout is applied to DSN generation or exporter DB connection config. This includes MySQL, MongoDB, PostgreSQL, ProxySQL, Valkey, and service flows that propagate the timeout to MySQL/PostgreSQL exporters behind RDS and Azure database monitoring.


Note

Medium Risk
Touches multiple CLI commands and expands protobuf APIs for several exporter types; risk is mainly around compatibility/serialization of the new duration field and ensuring it’s correctly propagated to all affected flows.

Overview
Adds a configurable connection_timeout for DSN/config-based exporters across add and change flows (MySQLd, MongoDB, PostgreSQL, ProxySQL, Valkey), wiring a new --connection-timeout CLI flag through admin commands into the inventory/management API payloads.

Introduces commands.DurationString (with tests) to serialize time.Duration flags consistently, and extends api/inventory/v1/agents.proto plus generated pb.go/validation code to carry connection_timeout as a google.protobuf.Duration with non-negative validation.

Reviewed by Cursor Bugbot for commit ca21749. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 66.55405% with 99 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.98%. Comparing base (b4e5544) to head (ca21749).

Files with missing lines Patch % Lines
managed/models/agent_model.go 76.36% 23 Missing and 3 partials ⚠️
managed/services/inventory/agents.go 69.69% 20 Missing ⚠️
managed/services/converters.go 18.18% 18 Missing ⚠️
admin/commands/management/add_valkey.go 0.00% 8 Missing ⚠️
.../commands/inventory/add_agent_postgres_exporter.go 0.00% 7 Missing ⚠️
...n/commands/inventory/add_agent_mongodb_exporter.go 0.00% 2 Missing ⚠️
...in/commands/inventory/add_agent_mysqld_exporter.go 0.00% 2 Missing ⚠️
.../commands/inventory/add_agent_proxysql_exporter.go 0.00% 2 Missing ⚠️
admin/commands/management/add_mongodb.go 0.00% 2 Missing ⚠️
admin/commands/management/add_mysql.go 0.00% 2 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #5275      +/-   ##
==========================================
+ Coverage   41.49%   42.98%   +1.49%     
==========================================
  Files         410      412       +2     
  Lines       41992    42073      +81     
==========================================
+ Hits        17424    18086     +662     
+ Misses      22814    22145     -669     
- Partials     1754     1842      +88     
Flag Coverage Δ
admin 34.94% <26.82%> (+0.04%) ⬆️
agent 49.24% <ø> (+2.61%) ⬆️
managed 41.94% <72.94%> (+1.33%) ⬆️
vmproxy 72.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread admin/commands/config.go

if cmd.LogLevelFatalFlags.LogLevel != "" {
res = append(res, fmt.Sprintf("--log-level=%s", cmd.LogLevelFatalFlags.LogLevel))
if cmd.LogLevel != "" {
Copy link
Copy Markdown
Contributor Author

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.

Comment on lines 121 to +123
int32 max_postgresql_exporter_connections = 33;
// Connection timeout for exporter (if set).
google.protobuf.Duration connection_timeout = 35 [(validate.rules).duration = {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

34 is not missed, it is above.

Comment thread admin/commands/helpers.go
Comment on lines +23 to +29
func DurationString(value *time.Duration) string {
if value == nil {
return ""
}

return strconv.FormatFloat(value.Seconds(), 'f', -1, 64) + "s"
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for #5134 (comment)

@JiriCtvrtka
Copy link
Copy Markdown
Contributor Author

Latest comments from Max on original PR are applied: #5134 (comment) and #5134 (comment)

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ca21749. Configure here.

ExposeExporter: cmd.ExposeExporter,
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change commands may unintentionally clear connection timeout

Medium Severity

DurationString returns a plain string ("" when nil), but change-agent commands need pointer semantics to distinguish "not specified" from "clear the value." Other optional fields in these same change commands (e.g., LogLevel via convertLogLevelPtr) correctly return *string so that nil means "don't modify." Because DurationString always produces a non-nil value, every change operation unconditionally sets ConnectionTimeout on the request body — risking clearing a previously configured timeout when the user only intended to update an unrelated property.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca21749. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants