@@ -11,7 +11,6 @@ const {
11
11
} = require ( '../../shim/specs' )
12
12
const { CURSOR_OPS , COLLECTION_OPS , DB_OPS } = require ( './constants' )
13
13
const common = module . exports
14
- common . NR_ATTRS = Symbol ( 'NR_ATTRS' )
15
14
16
15
/**
17
16
* Instruments all methods from constants.CURSOR_OPS on a given
@@ -88,8 +87,7 @@ common.instrumentDb = function instrumentDb(shim, Db) {
88
87
* Sets up the desc for all instrumented query methods
89
88
*
90
89
* @param {Shim } shim instance of shim
91
- * @param {Function } fn function getting instrumented
92
- * @param _fn
90
+ * @param {Function } _fn function getting instrumented
93
91
* @param {string } methodName name of function
94
92
* @returns {QuerySpec } query spec
95
93
*/
@@ -156,13 +154,10 @@ common.captureAttributesOnStarted = function captureAttributesOnStarted(
156
154
if ( connId ) {
157
155
// used in v3 when connection is a cluster pool
158
156
if ( typeof connId === 'number' ) {
159
- setHostPort ( shim , evnt . address , evnt . databaseName , this . $MongoClient )
157
+ setHostPort ( shim , evnt . address , evnt . databaseName )
160
158
// used in v3 when connection is to 1 host
161
159
} else if ( typeof connId === 'string' ) {
162
160
setHostPort ( shim , connId , evnt . databaseName )
163
- // v2 contains `domainSocket`, get socket connection from `host`
164
- } else if ( connId . domainSocket ) {
165
- shim . captureInstanceAttributes ( 'localhost' , connId . host , evnt . databaseName )
166
161
// v2 remote connection get `host` `port` from respective properties
167
162
} else {
168
163
shim . captureInstanceAttributes ( connId . host , connId . port , evnt . databaseName )
@@ -173,37 +168,14 @@ common.captureAttributesOnStarted = function captureAttributesOnStarted(
173
168
174
169
/**
175
170
* Extracts the host and port from a connection string
176
- * This also handles if connection string is a domain socket
177
- * Mongo sticks the path to the domain socket in the "host" slot, but we
178
- * want it in the "port", so if we have a domain socket we need to change
179
- * the order of our parameters.
180
171
*
181
172
* @param {Shim } shim instance of shim
182
173
* @param {string } connStr mongo connection string
183
174
* @param {string } db database name
184
- * @param {object } client mongo client instance
185
175
*/
186
- function setHostPort ( shim , connStr , db , client ) {
176
+ function setHostPort ( shim , connStr , db ) {
187
177
const parts = common . parseAddress ( connStr )
188
- // in v3 when running with a cluster of socket connections
189
- // the address is `undefined:undefined`. we will instead attempt
190
- // to get connection details from the client symbol NR_ATTRS
191
- // added in `lib/instrumentation/mongodb/v3-mongo` when a client connects
192
- // with a URL string
193
- if ( parts . includes ( 'undefined' ) ) {
194
- try {
195
- const attrs = client [ common . NR_ATTRS ]
196
- const socket = decodeURIComponent ( attrs . split ( ',' ) [ 0 ] . split ( 'mongodb://' ) [ 1 ] )
197
- shim . captureInstanceAttributes ( 'localhost' , socket , db )
198
- } catch ( err ) {
199
- shim . logger . debug ( err , 'Could not extract host/port from mongo command' )
200
- }
201
- // connected using domain socket but the "host"(e.g: /path/to/mongo-socket-port.sock)
202
- } else if ( parts . length && parts [ 0 ] [ 0 ] === '/' ) {
203
- shim . captureInstanceAttributes ( 'localhost' , parts [ 0 ] , db )
204
- } else {
205
- shim . captureInstanceAttributes ( parts [ 0 ] , parts [ 1 ] , db )
206
- }
178
+ shim . captureInstanceAttributes ( parts [ 0 ] , parts [ 1 ] , db )
207
179
}
208
180
209
181
/**
@@ -247,13 +219,8 @@ function getInstanceAttributeParameters(shim, mongo) {
247
219
* @returns {object } db params
248
220
*/
249
221
function getParametersFromHosts ( hosts , database ) {
250
- let [ { host, port } ] = hosts
251
- const [ { socketPath } ] = hosts
222
+ const [ { host, port } ] = hosts
252
223
253
- if ( socketPath ) {
254
- port = socketPath
255
- host = 'localhost'
256
- }
257
224
return new DatastoreParameters ( {
258
225
host,
259
226
port_path_or_id : port ,
@@ -284,13 +251,6 @@ function getParametersFromTopology(conf, database) {
284
251
; [ { host, port } ] = conf . s . options . hosts
285
252
}
286
253
287
- // host is a domain socket. set host as localhost and use the domain
288
- // socket host as the port
289
- if ( host && host . endsWith ( '.sock' ) ) {
290
- port = host
291
- host = 'localhost'
292
- }
293
-
294
254
return new DatastoreParameters ( {
295
255
host,
296
256
port_path_or_id : port ,
0 commit comments