Skip to content

Commit c8acbc5

Browse files
authored
feat: Add support for MongoDB.Driver 3.x and above. (#3065)
1 parent 81656b9 commit c8acbc5

File tree

4 files changed

+192
-90
lines changed

4 files changed

+192
-90
lines changed

build/Dotty/packageInfo.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@
103103
"packageName": "microsoft.net.http"
104104
},
105105
{
106-
"packageName": "mongodb.driver",
107-
"ignorePatch": true,
108-
"ignoreMinor": true,
109-
"ignoreMajor": true,
110-
"ignoreReason": "Breaking since at least 2.25.0. See https://new-relic.atlassian.net/browse/NR-281915"
106+
"packageName": "mongodb.driver"
111107
},
112108
{
113109
"packageName": "mysql.data"

src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/MongoDb26/Instrumentation.xml

+102-72
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0
55
-->
66
<extension xmlns="urn:newrelic-extension">
77
<instrumentation>
8+
89
<tracerFactory name="MongoCollectionImplWrapper">
910
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoCollectionImpl`1">
1011
<exactMethodMatcher methodName="AggregateAsync"/>
@@ -37,86 +38,115 @@ SPDX-License-Identifier: Apache-2.0
3738
</match>
3839
</tracerFactory>
3940

40-
<tracerFactory name="AsyncCursorWrapper">
41-
<match assemblyName="MongoDB.Driver.Core" className="MongoDB.Driver.Core.Operations.AsyncCursor`1">
42-
<exactMethodMatcher methodName="GetNextBatch"/>
43-
<exactMethodMatcher methodName="GetNextBatchAsync"/>
44-
</match>
45-
</tracerFactory>
41+
<tracerFactory name="AsyncCursorWrapper">
42+
<match assemblyName="MongoDB.Driver.Core" className="MongoDB.Driver.Core.Operations.AsyncCursor`1" maxVersion="3.0.0">
43+
<exactMethodMatcher methodName="GetNextBatch"/>
44+
<exactMethodMatcher methodName="GetNextBatchAsync"/>
45+
</match>
46+
47+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.Core.Operations.AsyncCursor`1" minVersion="3.0.0">
48+
<exactMethodMatcher methodName="GetNextBatch"/>
49+
<exactMethodMatcher methodName="GetNextBatchAsync"/>
50+
</match>
51+
</tracerFactory>
4652

47-
<tracerFactory name="MongoDatabaseWrapper">
48-
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoDatabaseImpl">
49-
<exactMethodMatcher methodName="Aggregate"/>
50-
<exactMethodMatcher methodName="AggregateToCollection"/>
51-
<exactMethodMatcher methodName="CreateCollection"/>
52-
<exactMethodMatcher methodName="CreateView"/>
53-
<exactMethodMatcher methodName="DropCollection"/>
54-
<exactMethodMatcher methodName="ListCollections"/>
55-
<exactMethodMatcher methodName="ListCollectionNames"/>
56-
<exactMethodMatcher methodName="RenameCollection"/>
57-
<exactMethodMatcher methodName="RunCommand"/>
58-
<exactMethodMatcher methodName="Watch"/>
53+
<tracerFactory name="MongoDatabaseWrapper">
54+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoDatabaseImpl" maxVersion="3.0.0">
55+
<exactMethodMatcher methodName="Aggregate"/>
56+
<exactMethodMatcher methodName="AggregateToCollection"/>
57+
<exactMethodMatcher methodName="CreateCollection"/>
58+
<exactMethodMatcher methodName="CreateView"/>
59+
<exactMethodMatcher methodName="DropCollection"/>
60+
<exactMethodMatcher methodName="ListCollections"/>
61+
<exactMethodMatcher methodName="ListCollectionNames"/>
62+
<exactMethodMatcher methodName="RenameCollection"/>
63+
<exactMethodMatcher methodName="RunCommand"/>
64+
<exactMethodMatcher methodName="Watch"/>
65+
66+
<exactMethodMatcher methodName="AggregateAsync"/>
67+
<exactMethodMatcher methodName="AggregateToCollectionAsync"/>
68+
<exactMethodMatcher methodName="CreateCollectionAsync"/>
69+
<exactMethodMatcher methodName="CreateViewAsync"/>
70+
<exactMethodMatcher methodName="DropCollectionAsync"/>
71+
<exactMethodMatcher methodName="ListCollectionsAsync"/>
72+
<exactMethodMatcher methodName="ListCollectionNamesAsync"/>
73+
<exactMethodMatcher methodName="RenameCollectionAsync"/>
74+
<exactMethodMatcher methodName="RunCommandAsync"/>
75+
<exactMethodMatcher methodName="WatchAsync"/>
76+
</match>
77+
78+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoDatabase" minVersion="3.0.0">
79+
<exactMethodMatcher methodName="Aggregate"/>
80+
<exactMethodMatcher methodName="AggregateToCollection"/>
81+
<exactMethodMatcher methodName="CreateCollection"/>
82+
<exactMethodMatcher methodName="CreateView"/>
83+
<exactMethodMatcher methodName="DropCollection"/>
84+
<exactMethodMatcher methodName="ListCollections"/>
85+
<exactMethodMatcher methodName="ListCollectionNames"/>
86+
<exactMethodMatcher methodName="RenameCollection"/>
87+
<exactMethodMatcher methodName="RunCommand"/>
88+
<exactMethodMatcher methodName="Watch"/>
5989

60-
<exactMethodMatcher methodName="AggregateAsync"/>
61-
<exactMethodMatcher methodName="AggregateToCollectionAsync"/>
62-
<exactMethodMatcher methodName="CreateCollectionAsync"/>
63-
<exactMethodMatcher methodName="CreateViewAsync"/>
64-
<exactMethodMatcher methodName="DropCollectionAsync"/>
65-
<exactMethodMatcher methodName="ListCollectionsAsync"/>
66-
<exactMethodMatcher methodName="ListCollectionNamesAsync"/>
67-
<exactMethodMatcher methodName="RenameCollectionAsync"/>
68-
<exactMethodMatcher methodName="RunCommandAsync"/>
69-
<exactMethodMatcher methodName="WatchAsync"/>
70-
</match>
71-
</tracerFactory>
90+
<exactMethodMatcher methodName="AggregateAsync"/>
91+
<exactMethodMatcher methodName="AggregateToCollectionAsync"/>
92+
<exactMethodMatcher methodName="CreateCollectionAsync"/>
93+
<exactMethodMatcher methodName="CreateViewAsync"/>
94+
<exactMethodMatcher methodName="DropCollectionAsync"/>
95+
<exactMethodMatcher methodName="ListCollectionsAsync"/>
96+
<exactMethodMatcher methodName="ListCollectionNamesAsync"/>
97+
<exactMethodMatcher methodName="RenameCollectionAsync"/>
98+
<exactMethodMatcher methodName="RunCommandAsync"/>
99+
<exactMethodMatcher methodName="WatchAsync"/>
100+
</match>
101+
</tracerFactory>
72102

73-
<tracerFactory name="MongoQueryProviderImplWrapper">
74-
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.Linq.MongoQueryProviderImpl`1">
75-
<exactMethodMatcher methodName="ExecuteModel"/>
76-
<exactMethodMatcher methodName="ExecuteModelAsync"/>
77-
</match>
78-
</tracerFactory>
103+
<tracerFactory name="MongoQueryProviderImplWrapper">
104+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.Linq.MongoQueryProviderImpl`1">
105+
<exactMethodMatcher methodName="ExecuteModel"/>
106+
<exactMethodMatcher methodName="ExecuteModelAsync"/>
107+
</match>
108+
</tracerFactory>
79109

80-
<tracerFactory name="MongoIndexManagerBaseWrapper">
81-
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoIndexManagerBase`1">
82-
<exactMethodMatcher methodName="CreateOne"/>
83-
<exactMethodMatcher methodName="CreateOneAsync"/>
84-
</match>
85-
</tracerFactory>
110+
<tracerFactory name="MongoIndexManagerBaseWrapper">
111+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoIndexManagerBase`1">
112+
<exactMethodMatcher methodName="CreateOne"/>
113+
<exactMethodMatcher methodName="CreateOneAsync"/>
114+
</match>
115+
</tracerFactory>
86116

87-
<tracerFactory name="MongoIndexManagerWrapper">
88-
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoCollectionImpl`1+MongoIndexManager">
89-
<exactMethodMatcher methodName="CreateMany"/>
90-
<exactMethodMatcher methodName="DropAll"/>
91-
<exactMethodMatcher methodName="DropOne"/>
92-
<exactMethodMatcher methodName="List"/>
117+
<tracerFactory name="MongoIndexManagerWrapper">
118+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoCollectionImpl`1+MongoIndexManager">
119+
<exactMethodMatcher methodName="CreateMany"/>
120+
<exactMethodMatcher methodName="DropAll"/>
121+
<exactMethodMatcher methodName="DropOne"/>
122+
<exactMethodMatcher methodName="List"/>
93123

94-
<exactMethodMatcher methodName="CreateManyAsync"/>
95-
<exactMethodMatcher methodName="DropAllAsync"/>
96-
<exactMethodMatcher methodName="DropOneAsync"/>
97-
<exactMethodMatcher methodName="ListAsync"/>
98-
</match>
99-
</tracerFactory>
124+
<exactMethodMatcher methodName="CreateManyAsync"/>
125+
<exactMethodMatcher methodName="DropAllAsync"/>
126+
<exactMethodMatcher methodName="DropOneAsync"/>
127+
<exactMethodMatcher methodName="ListAsync"/>
128+
</match>
129+
</tracerFactory>
100130

101-
<tracerFactory name="MongoCollectionBaseWrapper">
102-
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoCollectionBase`1">
103-
<exactMethodMatcher methodName="DeleteMany"/>
104-
<exactMethodMatcher methodName="DeleteOne"/>
105-
<exactMethodMatcher methodName="InsertOne"/>
106-
<exactMethodMatcher methodName="InsertMany"/>
107-
<exactMethodMatcher methodName="ReplaceOne"/>
108-
<exactMethodMatcher methodName="UpdateMany"/>
109-
<exactMethodMatcher methodName="UpdateOne"/>
131+
<tracerFactory name="MongoCollectionBaseWrapper">
132+
<match assemblyName="MongoDB.Driver" className="MongoDB.Driver.MongoCollectionBase`1">
133+
<exactMethodMatcher methodName="DeleteMany"/>
134+
<exactMethodMatcher methodName="DeleteOne"/>
135+
<exactMethodMatcher methodName="InsertOne"/>
136+
<exactMethodMatcher methodName="InsertMany"/>
137+
<exactMethodMatcher methodName="ReplaceOne"/>
138+
<exactMethodMatcher methodName="UpdateMany"/>
139+
<exactMethodMatcher methodName="UpdateOne"/>
110140

111-
<exactMethodMatcher methodName="DeleteManyAsync"/>
112-
<exactMethodMatcher methodName="DeleteOneAsync"/>
113-
<exactMethodMatcher methodName="InsertOneAsync"/>
114-
<exactMethodMatcher methodName="InsertManyAsync"/>
115-
<exactMethodMatcher methodName="ReplaceOneAsync"/>
116-
<exactMethodMatcher methodName="UpdateManyAsync"/>
117-
<exactMethodMatcher methodName="UpdateOneAsync"/>
118-
</match>
119-
</tracerFactory>
141+
<exactMethodMatcher methodName="DeleteManyAsync"/>
142+
<exactMethodMatcher methodName="DeleteOneAsync"/>
143+
<exactMethodMatcher methodName="InsertOneAsync"/>
144+
<exactMethodMatcher methodName="InsertManyAsync"/>
145+
<exactMethodMatcher methodName="ReplaceOneAsync"/>
146+
<exactMethodMatcher methodName="UpdateManyAsync"/>
147+
<exactMethodMatcher methodName="UpdateOneAsync"/>
148+
</match>
149+
</tracerFactory>
120150

121151
</instrumentation>
122152
</extension>

0 commit comments

Comments
 (0)