Commit 7e7ec49
committed
Backport MongoDB hosts array support to 3.x
Backport MongoDB integration fix from main branch to resolve broken
connection strings when using modern configuration format with hosts
array instead of legacy host/port parameters.
The current 3.x template generates malformed MongoDB URIs
(mongodb://user:pass@:/admin with missing host:port) when users
provide modern 'hosts' array parameters. This occurs because the
template expects old-style 'host' and 'port' keys but receives
'hosts' array from modern configurations, causing nil values in
the connection string.
Changes:
- Add dual-path template logic supporting both formats
- Modern configs with 'hosts' array use hosts format (works correctly)
- Legacy configs with 'host'/'port' use connection string (backward compatible)
- Add support for new MongoDB monitoring parameters:
- dbm: Database Monitoring feature
- database_autodiscovery: Auto-discovery of databases
- reported_database_hostname: Custom hostname for metrics
- Update documentation to deprecate host/port in favor of hosts
- Add RSpec tests for modern hosts array format
- Update CHANGELOG for unreleased changes
Template changes:
- Check if server['hosts'] exists and has elements
- If yes: render modern hosts array format with fields
- If no: fall back to legacy connection string format
- Add dbm, database_autodiscovery, reported_database_hostname rendering
Documentation changes:
- Move hosts, dbm, database_autodiscovery, reported_database_hostname to top
- Mark host and port as deprecated with recommendation to use hosts
- Update examples to show modern hosts array format
- Add link to official Datadog MongoDB integration docs
Test changes:
- Add test context for hosts array configuration
- Verify hosts array renders correctly
- Verify all new parameters render correctly
- Maintain backward compatibility with existing tests
Tested:
- pdk validate: PASSED
- Full test suite: 4895 examples, 0 failures, 63 pending
- Syntax validation: PASSED
Refs: 9472fc7
Refs: DataDog#838
Signed-off-by: Jaremy Hatler <j.hatler@xsolla.com>1 parent 7f93cb4 commit 7e7ec49
4 files changed
Lines changed: 81 additions & 8 deletions
File tree
- manifests/integrations
- spec/classes
- templates/agent-conf.d
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
8 | 19 | | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
12 | | - | |
13 | | - | |
14 | 23 | | |
15 | 24 | | |
16 | | - | |
17 | | - | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| |||
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
40 | 53 | | |
41 | 54 | | |
42 | 55 | | |
| |||
73 | 86 | | |
74 | 87 | | |
75 | 88 | | |
76 | | - | |
| 89 | + | |
77 | 90 | | |
78 | | - | |
79 | 91 | | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
83 | 95 | | |
84 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
85 | 100 | | |
86 | 101 | | |
87 | | - | |
88 | | - | |
| 102 | + | |
89 | 103 | | |
90 | 104 | | |
91 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
30 | 56 | | |
31 | 57 | | |
32 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
7 | 23 | | |
| 24 | + | |
8 | 25 | | |
9 | 26 | | |
10 | 27 | | |
| |||
50 | 67 | | |
51 | 68 | | |
52 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
53 | 82 | | |
0 commit comments