Skip to content

Commit

Permalink
Fixed naming of connection pool metrics (#19874)
Browse files Browse the repository at this point in the history
no refs
  • Loading branch information
mike182uk committed Mar 18, 2024
1 parent 715ff56 commit 949b157
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ghost/core/core/server/data/db/ConnectionPoolInstrumentation.js
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -139,4 +139,4 @@ class ConnectionPoolInstrumentation {
}
}

module.exports = ConnectionPoolInstrumentation;
module.exports = ConnectionPoolInstrumentation;

0 comments on commit 949b157

Please sign in to comment.