Skip to content

Commit d595634

Browse files
authored
chore: remove apm instrumentation decoration
NODE-3160
1 parent c529d43 commit d595634

21 files changed

+231
-527
lines changed

src/apm.ts

-56
This file was deleted.

src/cmap/events.ts renamed to src/cmap/command_monitoring_events.ts

+1-173
Original file line numberDiff line numberDiff line change
@@ -1,180 +1,8 @@
11
import { GetMore, KillCursor, Msg, WriteProtocolMessageType } from './commands';
22
import { calculateDurationInMs, deepCopy } from '../utils';
3-
import { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
3+
import type { ConnectionPool } from './connection_pool';
44
import type { Connection } from './connection';
55
import type { Document } from '../bson';
6-
import type { AnyError } from '../error';
7-
8-
/**
9-
* The base export class for all monitoring events published from the connection pool
10-
* @public
11-
* @category Event
12-
*/
13-
export class ConnectionPoolMonitoringEvent {
14-
/** A timestamp when the event was created */
15-
time: Date;
16-
/** The address (host/port pair) of the pool */
17-
address: string;
18-
19-
constructor(pool: ConnectionPool) {
20-
this.time = new Date();
21-
this.address = pool.address;
22-
}
23-
}
24-
25-
/**
26-
* An event published when a connection pool is created
27-
* @public
28-
* @category Event
29-
*/
30-
export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
31-
/** The options used to create this connection pool */
32-
options?: ConnectionPoolOptions;
33-
34-
constructor(pool: ConnectionPool) {
35-
super(pool);
36-
this.options = pool.options;
37-
}
38-
}
39-
40-
/**
41-
* An event published when a connection pool is closed
42-
* @public
43-
* @category Event
44-
*/
45-
export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
46-
constructor(pool: ConnectionPool) {
47-
super(pool);
48-
}
49-
}
50-
51-
/**
52-
* An event published when a connection pool creates a new connection
53-
* @public
54-
* @category Event
55-
*/
56-
export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
57-
/** A monotonically increasing, per-pool id for the newly created connection */
58-
connectionId: number | '<monitor>';
59-
60-
constructor(pool: ConnectionPool, connection: Connection) {
61-
super(pool);
62-
this.connectionId = connection.id;
63-
}
64-
}
65-
66-
/**
67-
* An event published when a connection is ready for use
68-
* @public
69-
* @category Event
70-
*/
71-
export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
72-
/** The id of the connection */
73-
connectionId: number | '<monitor>';
74-
75-
constructor(pool: ConnectionPool, connection: Connection) {
76-
super(pool);
77-
this.connectionId = connection.id;
78-
}
79-
}
80-
81-
/**
82-
* An event published when a connection is closed
83-
* @public
84-
* @category Event
85-
*/
86-
export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
87-
/** The id of the connection */
88-
connectionId: number | '<monitor>';
89-
/** The reason the connection was closed */
90-
reason: string;
91-
92-
constructor(pool: ConnectionPool, connection: Connection, reason: string) {
93-
super(pool);
94-
this.connectionId = connection.id;
95-
this.reason = reason || 'unknown';
96-
}
97-
}
98-
99-
/**
100-
* An event published when a request to check a connection out begins
101-
* @public
102-
* @category Event
103-
*/
104-
export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent {
105-
constructor(pool: ConnectionPool) {
106-
super(pool);
107-
}
108-
}
109-
110-
/**
111-
* An event published when a request to check a connection out fails
112-
* @public
113-
* @category Event
114-
*/
115-
export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent {
116-
/** The reason the attempt to check out failed */
117-
reason: AnyError | string;
118-
119-
constructor(pool: ConnectionPool, reason: AnyError | string) {
120-
super(pool);
121-
this.reason = reason;
122-
}
123-
}
124-
125-
/**
126-
* An event published when a connection is checked out of the connection pool
127-
* @public
128-
* @category Event
129-
*/
130-
export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
131-
/** The id of the connection */
132-
connectionId: number | '<monitor>';
133-
134-
constructor(pool: ConnectionPool, connection: Connection) {
135-
super(pool);
136-
this.connectionId = connection.id;
137-
}
138-
}
139-
140-
/**
141-
* An event published when a connection is checked into the connection pool
142-
* @public
143-
* @category Event
144-
*/
145-
export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
146-
/** The id of the connection */
147-
connectionId: number | '<monitor>';
148-
149-
constructor(pool: ConnectionPool, connection: Connection) {
150-
super(pool);
151-
this.connectionId = connection.id;
152-
}
153-
}
154-
155-
/**
156-
* An event published when a connection pool is cleared
157-
* @public
158-
* @category Event
159-
*/
160-
export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
161-
constructor(pool: ConnectionPool) {
162-
super(pool);
163-
}
164-
}
165-
166-
export const CMAP_EVENT_NAMES = [
167-
ConnectionPool.CONNECTION_POOL_CREATED,
168-
ConnectionPool.CONNECTION_POOL_CLOSED,
169-
ConnectionPool.CONNECTION_CREATED,
170-
ConnectionPool.CONNECTION_READY,
171-
ConnectionPool.CONNECTION_CLOSED,
172-
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
173-
ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
174-
ConnectionPool.CONNECTION_CHECKED_OUT,
175-
ConnectionPool.CONNECTION_CHECKED_IN,
176-
ConnectionPool.CONNECTION_POOL_CLEARED
177-
] as const;
1786

1797
/**
1808
* An event indicating the start of a given

src/cmap/connection.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { EventEmitter } from 'events';
22
import { MessageStream, OperationDescription } from './message_stream';
33
import { StreamDescription, StreamDescriptionOptions } from './stream_description';
4-
import { CommandStartedEvent, CommandFailedEvent, CommandSucceededEvent } from './events';
4+
import {
5+
CommandStartedEvent,
6+
CommandFailedEvent,
7+
CommandSucceededEvent
8+
} from './command_monitoring_events';
59
import { applySession, ClientSession, updateSessionFromResponse } from '../sessions';
610
import {
711
uuidV4,

src/cmap/connection_pool.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ConnectionCheckedOutEvent,
1818
ConnectionCheckedInEvent,
1919
ConnectionPoolClearedEvent
20-
} from './events';
20+
} from './connection_pool_events';
2121

2222
const kLogger = Symbol('logger');
2323
const kConnections = Symbol('connections');
@@ -522,6 +522,19 @@ function processWaitQueue(pool: ConnectionPool) {
522522
}
523523
}
524524

525+
export const CMAP_EVENT_NAMES = [
526+
ConnectionPool.CONNECTION_POOL_CREATED,
527+
ConnectionPool.CONNECTION_POOL_CLOSED,
528+
ConnectionPool.CONNECTION_CREATED,
529+
ConnectionPool.CONNECTION_READY,
530+
ConnectionPool.CONNECTION_CLOSED,
531+
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
532+
ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
533+
ConnectionPool.CONNECTION_CHECKED_OUT,
534+
ConnectionPool.CONNECTION_CHECKED_IN,
535+
ConnectionPool.CONNECTION_POOL_CLEARED
536+
] as const;
537+
525538
/**
526539
* A callback provided to `withConnection`
527540
* @public

0 commit comments

Comments
 (0)