Commit cce064e
Add support for DBM comment injection with MongoDB (#9589)
* Added support for DBM comment injection with MongoDB
* Moved SharedDBCommenter from jdbc instrumentation to dd-trace-core
* Fixed SharedDBCommenterTest import
* Replaced hardcoded length with constant
* Attempt at fixing existing tests
* Updated INJECT_COMMENT logic
* Fixed containsTraceComment for test cases
* Switched MongoDBMInjectionTest to MongoBaseTest
* Revamped Mongo comment tests
* Attempt to fix SQL injection tests
* Revert changes to gradle.lockfile
* PR comments: build traceparent incl. sampling flag, exception logging
* Add missing helperClassNames for mongo drivers 3.1 and 3.4
* Using unit testing for trace parent changes
* Prevented cloning immutable Mongo objects
* Fixed smoke test (revert bug)
* add new mongo instrumentation to inject APM/DBM comment
This is a draft that doesn't work yet. Tests are also missing
* add support for mongo driver version 4.3
I assumed that since the code was working on 4.0 and 5.6, then it worked
on all the intermediary versions. It seems that the API changed in 4.3,
but then was restored later in 4.4
* rename MongoCommentInjector's getComment to buildComment
* only create a mutable copy of the BsonDocument when needed
* move shared sql commenter to bootstrap package
* document why we check for existing span on command listener
* reformat trace parent util
* fix server connection instrumentation advice not working on write queries
Write queries on the MongoDB driver >= 4.0 and <= 4.7 weren't correctly
instrumented. I didn't notice it before because the tests weren't
exhaustive, and my test app was using driver v5.6.
* improve check for overload instrumentation
* add missing helper class for mongo 3.1 instrumentation
* move mongo < 4.0 to standalone package driver-3.6
In the end, the instrumentation only works on driver > 3.6, so we
decided to make a standalone package for that. This version being 9
years old seems to be enough for DBM support
* add mock method to force the DefaultServerConnection40Instrumentation to run on driver > 4.0 only
* Move DefaultServerInstrumentation for mongo driver 4.0 to driver 3.8
We now have two instrumentations: one for 3.6 to 3.7, and another one
for 3.8 to 5.6
---------
Co-authored-by: Naji Astier <[email protected]>1 parent 45bc239 commit cce064e
File tree
30 files changed
+2107
-126
lines changed- .github
- dd-java-agent
- agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/dbm
- instrumentation
- jdbc/src/main/java/datadog/trace/instrumentation/jdbc
- mongo
- common
- src
- main/java/datadog/trace/instrumentation/mongo
- test/groovy
- driver-3.10-sync-test
- driver-3.6
- src
- main/java/datadog/trace/instrumentation/mongo
- test/groovy
- driver-3.7-core-test
- driver-3.8
- src
- main/java/datadog/trace/instrumentation/mongo
- test/groovy
- driver-4.0
- src/test/groovy
- src/test/groovy
- dd-smoke-tests/springboot-mongo/src/test/groovy/datadog/smoketest
- dd-trace-core/src/test/groovy/datadog/trace/core/database
- internal-api/src/main/java/datadog/trace/api
30 files changed
+2107
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
Lines changed: 107 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 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 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
113 | | - | |
114 | | - | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
Lines changed: 2 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | | - | |
52 | | - | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | 420 | | |
426 | 421 | | |
427 | 422 | | |
| |||
Lines changed: 31 additions & 109 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 3 | + | |
14 | 4 | | |
15 | 5 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 6 | + | |
22 | 7 | | |
23 | 8 | | |
24 | 9 | | |
25 | 10 | | |
26 | 11 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
45 | 17 | | |
46 | 18 | | |
47 | 19 | | |
| |||
99 | 71 | | |
100 | 72 | | |
101 | 73 | | |
102 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
103 | 80 | | |
104 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
105 | 84 | | |
106 | 85 | | |
107 | 86 | | |
| |||
113 | 92 | | |
114 | 93 | | |
115 | 94 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 95 | + | |
132 | 96 | | |
133 | 97 | | |
134 | 98 | | |
| |||
142 | 106 | | |
143 | 107 | | |
144 | 108 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 109 | | |
155 | 110 | | |
156 | 111 | | |
157 | 112 | | |
158 | 113 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | 114 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 115 | + | |
| 116 | + | |
180 | 117 | | |
181 | 118 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
205 | 128 | | |
206 | | - | |
207 | | - | |
208 | | - | |
| 129 | + | |
| 130 | + | |
209 | 131 | | |
210 | | - | |
| 132 | + | |
211 | 133 | | |
212 | 134 | | |
213 | 135 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
| 9 | + | |
6 | 10 | | |
0 commit comments