mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
parent
715ff56032
commit
949b157775
1 changed files with 8 additions and 8 deletions
|
@ -24,7 +24,7 @@ class ConnectionPoolInstrumentation {
|
|||
this.createStartTimes[eventId] = Date.now();
|
||||
const poolMetrics = this.getPoolMetrics();
|
||||
this.logging.debug(`[ConnectionPool] Creating a connection. EventID: ${eventId} Pending Creates: ${poolMetrics.numPendingCreates} Free: ${poolMetrics.numFree} Used: ${poolMetrics.numUsed}`);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'create-request',
|
||||
eventId,
|
||||
...poolMetrics
|
||||
|
@ -37,7 +37,7 @@ class ConnectionPoolInstrumentation {
|
|||
// Delete the start time so we don't leak memory
|
||||
delete this.createStartTimes[eventId];
|
||||
this.logging.debug(`[ConnectionPool] Created a connection. EventID: ${eventId} Connection ID: ${resource.connectionId} Knex ID: ${resource.__knexUid} Time to Create: ${timeToCreate}ms`);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'create-success',
|
||||
eventId,
|
||||
connectionId: resource.connectionId,
|
||||
|
@ -53,7 +53,7 @@ class ConnectionPoolInstrumentation {
|
|||
delete this.createStartTimes[eventId];
|
||||
const poolMetrics = this.getPoolMetrics();
|
||||
this.logging.error(`[ConnectionPool] Failed to create a connection. EventID: ${eventId} Time to Create: ${timeToFail}ms`, err);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'create-fail',
|
||||
eventId,
|
||||
timeToFail,
|
||||
|
@ -66,7 +66,7 @@ class ConnectionPoolInstrumentation {
|
|||
this.requestStartTimes[eventId] = Date.now();
|
||||
const poolMetrics = this.getPoolMetrics();
|
||||
this.logging.debug(`[ConnectionPool] Acquiring a connection. EventID: ${eventId} Pending Acquires: ${poolMetrics.numPendingAcquires} Free: ${poolMetrics.numFree} Used: ${poolMetrics.numUsed}`);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'acquire-request',
|
||||
eventId,
|
||||
...poolMetrics
|
||||
|
@ -81,7 +81,7 @@ class ConnectionPoolInstrumentation {
|
|||
// Track when the connection was acquired for calculating lifetime upon release
|
||||
resource.connectionAcquired = Date.now();
|
||||
this.logging.debug(`[ConnectionPool] Acquired a connection. EventID: ${eventId} Connection ID: ${resource.connectionId} Knex Id: ${resource.__knexUid} Time to Acquire: ${timeToAcquire}ms`);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'acquire-success',
|
||||
eventId,
|
||||
connectionId: resource.connectionId,
|
||||
|
@ -97,7 +97,7 @@ class ConnectionPoolInstrumentation {
|
|||
delete this.requestStartTimes[eventId];
|
||||
const poolMetrics = this.getPoolMetrics();
|
||||
this.logging.error(`[ConnectionPool] Failed to acquire a connection. EventID: ${eventId} Time to Acquire: ${timeToFail}ms`, err);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'acquire-fail',
|
||||
eventId,
|
||||
timeToFail,
|
||||
|
@ -108,7 +108,7 @@ class ConnectionPoolInstrumentation {
|
|||
handleRelease(resource) {
|
||||
const lifetime = Date.now() - resource.connectionAcquired;
|
||||
this.logging.debug(`[ConnectionPool] Released a connection. Connection ID: ${resource.connectionId} Lifetime: ${lifetime}ms`);
|
||||
this.metrics.metric('metrics-connection-pool', {
|
||||
this.metrics.metric('connection-pool', {
|
||||
event: 'release',
|
||||
connectionId: resource.connectionId,
|
||||
knexUid: resource.__knexUid,
|
||||
|
@ -139,4 +139,4 @@ class ConnectionPoolInstrumentation {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ConnectionPoolInstrumentation;
|
||||
module.exports = ConnectionPoolInstrumentation;
|
||||
|
|
Loading…
Add table
Reference in a new issue