@opentelemetry/instrumentation-mysql 0.48.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
2
|
import { MySQLInstrumentationConfig } from './types';
|
|
3
|
-
import { MeterProvider } from '@opentelemetry/api';
|
|
4
3
|
export declare class MySQLInstrumentation extends InstrumentationBase<MySQLInstrumentationConfig> {
|
|
5
4
|
static readonly COMMON_ATTRIBUTES: {
|
|
6
5
|
"db.system": string;
|
|
7
6
|
};
|
|
8
7
|
private _connectionsUsage;
|
|
9
8
|
constructor(config?: MySQLInstrumentationConfig);
|
|
10
|
-
|
|
11
|
-
private _setMetricInstruments;
|
|
9
|
+
protected _updateMetricInstruments(): void;
|
|
12
10
|
protected init(): InstrumentationNodeModuleDefinition[];
|
|
13
11
|
private _patchCreateConnection;
|
|
14
12
|
private _patchCreatePool;
|
|
@@ -29,13 +29,8 @@ class MySQLInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
29
29
|
};
|
|
30
30
|
constructor(config = {}) {
|
|
31
31
|
super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, config);
|
|
32
|
-
this._setMetricInstruments();
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
super.setMeterProvider(meterProvider);
|
|
36
|
-
this._setMetricInstruments();
|
|
37
|
-
}
|
|
38
|
-
_setMetricInstruments() {
|
|
33
|
+
_updateMetricInstruments() {
|
|
39
34
|
this._connectionsUsage = this.meter.createUpDownCounter('db.client.connections.usage', //TODO:: use semantic convention
|
|
40
35
|
{
|
|
41
36
|
description: 'The number of connections that are currently in state described by the state attribute.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;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C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE;YAC9B,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACnC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YACH,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE;gBAClC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE;YAC9B,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACnC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YACH,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE;gBAClC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AA1XU,oDAAoB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n context,\n Context,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n} from '@opentelemetry/instrumentation';\nimport {\n DBSYSTEMVALUES_MYSQL,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n} from '@opentelemetry/semantic-conventions';\nimport type * as mysqlTypes from 'mysql';\nimport { AttributeNames } from './AttributeNames';\nimport { MySQLInstrumentationConfig } from './types';\nimport {\n getConnectionAttributes,\n getDbStatement,\n getDbValues,\n getSpanName,\n getPoolName,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { UpDownCounter, MeterProvider } from '@opentelemetry/api';\n\ntype getConnectionCallbackType = (\n err: mysqlTypes.MysqlError,\n connection: mysqlTypes.PoolConnection\n) => void;\n\nexport class MySQLInstrumentation extends InstrumentationBase<MySQLInstrumentationConfig> {\n static readonly COMMON_ATTRIBUTES = {\n [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MYSQL,\n };\n private declare _connectionsUsage: UpDownCounter;\n\n constructor(config: MySQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this._setMetricInstruments();\n }\n\n override setMeterProvider(meterProvider: MeterProvider) {\n super.setMeterProvider(meterProvider);\n this._setMetricInstruments();\n }\n\n private _setMetricInstruments() {\n this._connectionsUsage = this.meter.createUpDownCounter(\n 'db.client.connections.usage', //TODO:: use semantic convention\n {\n description:\n 'The number of connections that are currently in state described by the state attribute.',\n unit: '{connection}',\n }\n );\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql',\n ['>=2.0.0 <3'],\n (moduleExports: typeof mysqlTypes) => {\n if (isWrapped(moduleExports.createConnection)) {\n this._unwrap(moduleExports, 'createConnection');\n }\n this._wrap(\n moduleExports,\n 'createConnection',\n this._patchCreateConnection() as any\n );\n\n if (isWrapped(moduleExports.createPool)) {\n this._unwrap(moduleExports, 'createPool');\n }\n this._wrap(\n moduleExports,\n 'createPool',\n this._patchCreatePool() as any\n );\n\n if (isWrapped(moduleExports.createPoolCluster)) {\n this._unwrap(moduleExports, 'createPoolCluster');\n }\n this._wrap(\n moduleExports,\n 'createPoolCluster',\n this._patchCreatePoolCluster() as any\n );\n\n return moduleExports;\n },\n (moduleExports: typeof mysqlTypes) => {\n if (moduleExports === undefined) return;\n this._unwrap(moduleExports, 'createConnection');\n this._unwrap(moduleExports, 'createPool');\n this._unwrap(moduleExports, 'createPoolCluster');\n }\n ),\n ];\n }\n\n // global export function\n private _patchCreateConnection() {\n return (originalCreateConnection: Function) => {\n const thisPlugin = this;\n\n return function createConnection(\n _connectionUri: string | mysqlTypes.ConnectionConfig\n ) {\n const originalResult = originalCreateConnection(...arguments);\n\n // This is unwrapped on next call after unpatch\n thisPlugin._wrap(\n originalResult,\n 'query',\n thisPlugin._patchQuery(originalResult) as any\n );\n\n return originalResult;\n };\n };\n }\n\n // global export function\n private _patchCreatePool() {\n return (originalCreatePool: Function) => {\n const thisPlugin = this;\n return function createPool(_config: string | mysqlTypes.PoolConfig) {\n const pool = originalCreatePool(...arguments);\n\n thisPlugin._wrap(pool, 'query', thisPlugin._patchQuery(pool));\n thisPlugin._wrap(\n pool,\n 'getConnection',\n thisPlugin._patchGetConnection(pool)\n );\n thisPlugin._wrap(pool, 'end', thisPlugin._patchPoolEnd(pool));\n thisPlugin._setPoolcallbacks(pool, thisPlugin, '');\n\n return pool;\n };\n };\n }\n private _patchPoolEnd(pool: any) {\n return (originalPoolEnd: Function) => {\n const thisPlugin = this;\n return function end(callback?: unknown) {\n const nAll = (pool as any)._allConnections.length;\n const nFree = (pool as any)._freeConnections.length;\n const nUsed = nAll - nFree;\n const poolName = getPoolName(pool);\n thisPlugin._connectionsUsage.add(-nUsed, {\n state: 'used',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(-nFree, {\n state: 'idle',\n name: poolName,\n });\n originalPoolEnd.apply(pool, arguments);\n };\n };\n }\n\n // global export function\n private _patchCreatePoolCluster() {\n return (originalCreatePoolCluster: Function) => {\n const thisPlugin = this;\n return function createPool(_config: string | mysqlTypes.PoolConfig) {\n const cluster = originalCreatePoolCluster(...arguments);\n\n // This is unwrapped on next call after unpatch\n thisPlugin._wrap(\n cluster,\n 'getConnection',\n thisPlugin._patchGetConnection(cluster)\n );\n thisPlugin._wrap(cluster, 'add', thisPlugin._patchAdd(cluster));\n\n return cluster;\n };\n };\n }\n private _patchAdd(cluster: mysqlTypes.PoolCluster) {\n return (originalAdd: Function) => {\n const thisPlugin = this;\n return function add(id: string, config: unknown) {\n // Unwrap if unpatch has been called\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(cluster, 'add');\n return originalAdd.apply(cluster, arguments);\n }\n originalAdd.apply(cluster, arguments);\n const nodes = cluster['_nodes' as keyof mysqlTypes.PoolCluster] as any;\n if (nodes) {\n const nodeId =\n typeof id === 'object'\n ? 'CLUSTER::' + (cluster as any)._lastId\n : String(id);\n\n const pool = nodes[nodeId].pool;\n thisPlugin._setPoolcallbacks(pool, thisPlugin, id);\n }\n };\n };\n }\n\n // method on cluster or pool\n private _patchGetConnection(pool: mysqlTypes.Pool | mysqlTypes.PoolCluster) {\n return (originalGetConnection: Function) => {\n const thisPlugin = this;\n\n return function getConnection(\n arg1?: unknown,\n arg2?: unknown,\n arg3?: unknown\n ) {\n // Unwrap if unpatch has been called\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(pool, 'getConnection');\n return originalGetConnection.apply(pool, arguments);\n }\n\n if (arguments.length === 1 && typeof arg1 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg1 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, patchFn);\n }\n if (arguments.length === 2 && typeof arg2 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg2 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, arg1, patchFn);\n }\n if (arguments.length === 3 && typeof arg3 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg3 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, arg1, arg2, patchFn);\n }\n\n return originalGetConnection.apply(pool, arguments);\n };\n };\n }\n\n private _getConnectionCallbackPatchFn(cb: getConnectionCallbackType) {\n const thisPlugin = this;\n const activeContext = context.active();\n return function (\n this: any,\n err: mysqlTypes.MysqlError,\n connection: mysqlTypes.PoolConnection\n ) {\n if (connection) {\n // this is the callback passed into a query\n // no need to unwrap\n if (!isWrapped(connection.query)) {\n thisPlugin._wrap(\n connection,\n 'query',\n thisPlugin._patchQuery(connection)\n );\n }\n }\n if (typeof cb === 'function') {\n context.with(activeContext, cb, this, err, connection);\n }\n };\n }\n\n private _patchQuery(connection: mysqlTypes.Connection | mysqlTypes.Pool) {\n return (originalQuery: Function): mysqlTypes.QueryFunction => {\n const thisPlugin = this;\n\n return function query(\n query: string | mysqlTypes.Query | mysqlTypes.QueryOptions,\n _valuesOrCallback?: unknown[] | mysqlTypes.queryCallback,\n _callback?: mysqlTypes.queryCallback\n ) {\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(connection, 'query');\n return originalQuery.apply(connection, arguments);\n }\n\n const span = thisPlugin.tracer.startSpan(getSpanName(query), {\n kind: SpanKind.CLIENT,\n attributes: {\n ...MySQLInstrumentation.COMMON_ATTRIBUTES,\n ...getConnectionAttributes(connection.config),\n },\n });\n\n span.setAttribute(SEMATTRS_DB_STATEMENT, getDbStatement(query));\n\n if (thisPlugin.getConfig().enhancedDatabaseReporting) {\n let values;\n\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n span.setAttribute(\n AttributeNames.MYSQL_VALUES,\n getDbValues(query, values)\n );\n }\n\n const cbIndex = Array.from(arguments).findIndex(\n arg => typeof arg === 'function'\n );\n\n const parentContext = context.active();\n\n if (cbIndex === -1) {\n const streamableQuery: mysqlTypes.Query = context.with(\n trace.setSpan(context.active(), span),\n () => {\n return originalQuery.apply(connection, arguments);\n }\n );\n context.bind(parentContext, streamableQuery);\n\n return streamableQuery\n .on('error', err =>\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n })\n )\n .on('end', () => {\n span.end();\n });\n } else {\n thisPlugin._wrap(\n arguments,\n cbIndex,\n thisPlugin._patchCallbackQuery(span, parentContext)\n );\n\n return context.with(trace.setSpan(context.active(), span), () => {\n return originalQuery.apply(connection, arguments);\n });\n }\n };\n };\n }\n\n private _patchCallbackQuery(span: Span, parentContext: Context) {\n return (originalCallback: Function) => {\n return function (\n err: mysqlTypes.MysqlError | null,\n results?: any,\n fields?: mysqlTypes.FieldInfo[]\n ) {\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n }\n span.end();\n return context.with(parentContext, () =>\n originalCallback(...arguments)\n );\n };\n };\n }\n private _setPoolcallbacks(\n pool: mysqlTypes.Pool,\n thisPlugin: MySQLInstrumentation,\n id: string\n ) {\n //TODO:: use semantic convention\n const poolName = id || getPoolName(pool);\n\n pool.on('connection', connection => {\n thisPlugin._connectionsUsage.add(1, {\n state: 'idle',\n name: poolName,\n });\n });\n\n pool.on('acquire', connection => {\n thisPlugin._connectionsUsage.add(-1, {\n state: 'idle',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(1, {\n state: 'used',\n name: poolName,\n });\n });\n\n pool.on('release', connection => {\n thisPlugin._connectionsUsage.add(-1, {\n state: 'used',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(1, {\n state: 'idle',\n name: poolName,\n });\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAO4B;AAC5B,oEAIwC;AACxC,8EAI6C;AAE7C,qDAAkD;AAElD,mCAMiB;AACjB,kBAAkB;AAClB,uCAA0D;AAQ1D,MAAa,oBAAqB,SAAQ,qCAA+C;IACvF,MAAM,CAAU,iBAAiB,GAAG;QAClC,CAAC,yCAAkB,CAAC,EAAE,2CAAoB;KAC3C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AAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE;YAC9B,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBACnC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YACH,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE;gBAClC,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AApXU,oDAAoB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n context,\n Context,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n} from '@opentelemetry/instrumentation';\nimport {\n DBSYSTEMVALUES_MYSQL,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n} from '@opentelemetry/semantic-conventions';\nimport type * as mysqlTypes from 'mysql';\nimport { AttributeNames } from './AttributeNames';\nimport { MySQLInstrumentationConfig } from './types';\nimport {\n getConnectionAttributes,\n getDbStatement,\n getDbValues,\n getSpanName,\n getPoolName,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { UpDownCounter } from '@opentelemetry/api';\n\ntype getConnectionCallbackType = (\n err: mysqlTypes.MysqlError,\n connection: mysqlTypes.PoolConnection\n) => void;\n\nexport class MySQLInstrumentation extends InstrumentationBase<MySQLInstrumentationConfig> {\n static readonly COMMON_ATTRIBUTES = {\n [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MYSQL,\n };\n private declare _connectionsUsage: UpDownCounter;\n\n constructor(config: MySQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n protected override _updateMetricInstruments() {\n this._connectionsUsage = this.meter.createUpDownCounter(\n 'db.client.connections.usage', //TODO:: use semantic convention\n {\n description:\n 'The number of connections that are currently in state described by the state attribute.',\n unit: '{connection}',\n }\n );\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql',\n ['>=2.0.0 <3'],\n (moduleExports: typeof mysqlTypes) => {\n if (isWrapped(moduleExports.createConnection)) {\n this._unwrap(moduleExports, 'createConnection');\n }\n this._wrap(\n moduleExports,\n 'createConnection',\n this._patchCreateConnection() as any\n );\n\n if (isWrapped(moduleExports.createPool)) {\n this._unwrap(moduleExports, 'createPool');\n }\n this._wrap(\n moduleExports,\n 'createPool',\n this._patchCreatePool() as any\n );\n\n if (isWrapped(moduleExports.createPoolCluster)) {\n this._unwrap(moduleExports, 'createPoolCluster');\n }\n this._wrap(\n moduleExports,\n 'createPoolCluster',\n this._patchCreatePoolCluster() as any\n );\n\n return moduleExports;\n },\n (moduleExports: typeof mysqlTypes) => {\n if (moduleExports === undefined) return;\n this._unwrap(moduleExports, 'createConnection');\n this._unwrap(moduleExports, 'createPool');\n this._unwrap(moduleExports, 'createPoolCluster');\n }\n ),\n ];\n }\n\n // global export function\n private _patchCreateConnection() {\n return (originalCreateConnection: Function) => {\n const thisPlugin = this;\n\n return function createConnection(\n _connectionUri: string | mysqlTypes.ConnectionConfig\n ) {\n const originalResult = originalCreateConnection(...arguments);\n\n // This is unwrapped on next call after unpatch\n thisPlugin._wrap(\n originalResult,\n 'query',\n thisPlugin._patchQuery(originalResult) as any\n );\n\n return originalResult;\n };\n };\n }\n\n // global export function\n private _patchCreatePool() {\n return (originalCreatePool: Function) => {\n const thisPlugin = this;\n return function createPool(_config: string | mysqlTypes.PoolConfig) {\n const pool = originalCreatePool(...arguments);\n\n thisPlugin._wrap(pool, 'query', thisPlugin._patchQuery(pool));\n thisPlugin._wrap(\n pool,\n 'getConnection',\n thisPlugin._patchGetConnection(pool)\n );\n thisPlugin._wrap(pool, 'end', thisPlugin._patchPoolEnd(pool));\n thisPlugin._setPoolcallbacks(pool, thisPlugin, '');\n\n return pool;\n };\n };\n }\n private _patchPoolEnd(pool: any) {\n return (originalPoolEnd: Function) => {\n const thisPlugin = this;\n return function end(callback?: unknown) {\n const nAll = (pool as any)._allConnections.length;\n const nFree = (pool as any)._freeConnections.length;\n const nUsed = nAll - nFree;\n const poolName = getPoolName(pool);\n thisPlugin._connectionsUsage.add(-nUsed, {\n state: 'used',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(-nFree, {\n state: 'idle',\n name: poolName,\n });\n originalPoolEnd.apply(pool, arguments);\n };\n };\n }\n\n // global export function\n private _patchCreatePoolCluster() {\n return (originalCreatePoolCluster: Function) => {\n const thisPlugin = this;\n return function createPool(_config: string | mysqlTypes.PoolConfig) {\n const cluster = originalCreatePoolCluster(...arguments);\n\n // This is unwrapped on next call after unpatch\n thisPlugin._wrap(\n cluster,\n 'getConnection',\n thisPlugin._patchGetConnection(cluster)\n );\n thisPlugin._wrap(cluster, 'add', thisPlugin._patchAdd(cluster));\n\n return cluster;\n };\n };\n }\n private _patchAdd(cluster: mysqlTypes.PoolCluster) {\n return (originalAdd: Function) => {\n const thisPlugin = this;\n return function add(id: string, config: unknown) {\n // Unwrap if unpatch has been called\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(cluster, 'add');\n return originalAdd.apply(cluster, arguments);\n }\n originalAdd.apply(cluster, arguments);\n const nodes = cluster['_nodes' as keyof mysqlTypes.PoolCluster] as any;\n if (nodes) {\n const nodeId =\n typeof id === 'object'\n ? 'CLUSTER::' + (cluster as any)._lastId\n : String(id);\n\n const pool = nodes[nodeId].pool;\n thisPlugin._setPoolcallbacks(pool, thisPlugin, id);\n }\n };\n };\n }\n\n // method on cluster or pool\n private _patchGetConnection(pool: mysqlTypes.Pool | mysqlTypes.PoolCluster) {\n return (originalGetConnection: Function) => {\n const thisPlugin = this;\n\n return function getConnection(\n arg1?: unknown,\n arg2?: unknown,\n arg3?: unknown\n ) {\n // Unwrap if unpatch has been called\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(pool, 'getConnection');\n return originalGetConnection.apply(pool, arguments);\n }\n\n if (arguments.length === 1 && typeof arg1 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg1 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, patchFn);\n }\n if (arguments.length === 2 && typeof arg2 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg2 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, arg1, patchFn);\n }\n if (arguments.length === 3 && typeof arg3 === 'function') {\n const patchFn = thisPlugin._getConnectionCallbackPatchFn(\n arg3 as getConnectionCallbackType\n );\n return originalGetConnection.call(pool, arg1, arg2, patchFn);\n }\n\n return originalGetConnection.apply(pool, arguments);\n };\n };\n }\n\n private _getConnectionCallbackPatchFn(cb: getConnectionCallbackType) {\n const thisPlugin = this;\n const activeContext = context.active();\n return function (\n this: any,\n err: mysqlTypes.MysqlError,\n connection: mysqlTypes.PoolConnection\n ) {\n if (connection) {\n // this is the callback passed into a query\n // no need to unwrap\n if (!isWrapped(connection.query)) {\n thisPlugin._wrap(\n connection,\n 'query',\n thisPlugin._patchQuery(connection)\n );\n }\n }\n if (typeof cb === 'function') {\n context.with(activeContext, cb, this, err, connection);\n }\n };\n }\n\n private _patchQuery(connection: mysqlTypes.Connection | mysqlTypes.Pool) {\n return (originalQuery: Function): mysqlTypes.QueryFunction => {\n const thisPlugin = this;\n\n return function query(\n query: string | mysqlTypes.Query | mysqlTypes.QueryOptions,\n _valuesOrCallback?: unknown[] | mysqlTypes.queryCallback,\n _callback?: mysqlTypes.queryCallback\n ) {\n if (!thisPlugin['_enabled']) {\n thisPlugin._unwrap(connection, 'query');\n return originalQuery.apply(connection, arguments);\n }\n\n const span = thisPlugin.tracer.startSpan(getSpanName(query), {\n kind: SpanKind.CLIENT,\n attributes: {\n ...MySQLInstrumentation.COMMON_ATTRIBUTES,\n ...getConnectionAttributes(connection.config),\n },\n });\n\n span.setAttribute(SEMATTRS_DB_STATEMENT, getDbStatement(query));\n\n if (thisPlugin.getConfig().enhancedDatabaseReporting) {\n let values;\n\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n span.setAttribute(\n AttributeNames.MYSQL_VALUES,\n getDbValues(query, values)\n );\n }\n\n const cbIndex = Array.from(arguments).findIndex(\n arg => typeof arg === 'function'\n );\n\n const parentContext = context.active();\n\n if (cbIndex === -1) {\n const streamableQuery: mysqlTypes.Query = context.with(\n trace.setSpan(context.active(), span),\n () => {\n return originalQuery.apply(connection, arguments);\n }\n );\n context.bind(parentContext, streamableQuery);\n\n return streamableQuery\n .on('error', err =>\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n })\n )\n .on('end', () => {\n span.end();\n });\n } else {\n thisPlugin._wrap(\n arguments,\n cbIndex,\n thisPlugin._patchCallbackQuery(span, parentContext)\n );\n\n return context.with(trace.setSpan(context.active(), span), () => {\n return originalQuery.apply(connection, arguments);\n });\n }\n };\n };\n }\n\n private _patchCallbackQuery(span: Span, parentContext: Context) {\n return (originalCallback: Function) => {\n return function (\n err: mysqlTypes.MysqlError | null,\n results?: any,\n fields?: mysqlTypes.FieldInfo[]\n ) {\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n }\n span.end();\n return context.with(parentContext, () =>\n originalCallback(...arguments)\n );\n };\n };\n }\n private _setPoolcallbacks(\n pool: mysqlTypes.Pool,\n thisPlugin: MySQLInstrumentation,\n id: string\n ) {\n //TODO:: use semantic convention\n const poolName = id || getPoolName(pool);\n\n pool.on('connection', connection => {\n thisPlugin._connectionsUsage.add(1, {\n state: 'idle',\n name: poolName,\n });\n });\n\n pool.on('acquire', connection => {\n thisPlugin._connectionsUsage.add(-1, {\n state: 'idle',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(1, {\n state: 'used',\n name: poolName,\n });\n });\n\n pool.on('release', connection => {\n thisPlugin._connectionsUsage.add(-1, {\n state: 'used',\n name: poolName,\n });\n thisPlugin._connectionsUsage.add(1, {\n state: 'idle',\n name: poolName,\n });\n });\n }\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
package/build/src/version.js
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.PACKAGE_VERSION = '0.
|
|
20
|
+
exports.PACKAGE_VERSION = '0.50.0';
|
|
21
21
|
exports.PACKAGE_NAME = '@opentelemetry/instrumentation-mysql';
|
|
22
22
|
//# sourceMappingURL=version.js.map
|
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,sCAAsC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,sCAAsC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.50.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-mysql';\n"]}
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-mysql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for `mysql` database client for MySQL",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/open-telemetry/opentelemetry-js-contrib.git",
|
|
10
|
+
"directory": "packages/instrumentation-mysql"
|
|
11
|
+
},
|
|
8
12
|
"scripts": {
|
|
9
13
|
"clean": "rimraf build/*",
|
|
10
|
-
"setup:dev": "nx run-many -t compile -p @opentelemetry/instrumentation-mysql",
|
|
11
14
|
"compile": "tsc -p .",
|
|
12
|
-
"
|
|
13
|
-
"lint": "eslint . --ext
|
|
15
|
+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-mysql",
|
|
16
|
+
"lint:fix": "eslint . --ext=ts,js,mjs --fix",
|
|
17
|
+
"lint": "eslint . --ext=ts,js,mjs",
|
|
14
18
|
"prepublishOnly": "npm run compile",
|
|
15
19
|
"tdd": "npm run test -- --watch-extensions ts --watch",
|
|
16
|
-
"test": "nyc mocha 'test/**/*.test.ts'",
|
|
17
|
-
"
|
|
20
|
+
"test": "nyc --no-clean mocha 'test/**/*.test.ts'",
|
|
21
|
+
"test:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test",
|
|
22
|
+
"test-merge-coverage": "nyc merge .nyc_output coverage/coverage-final.json",
|
|
23
|
+
"//todo": "echo \"add test-all-versions\"",
|
|
24
|
+
"test-services:start": "cd ../.. && npm run test-services:start mysql",
|
|
25
|
+
"test-services:stop": "cd ../.. && npm run test-services:stop mysql",
|
|
26
|
+
"version:update": "node ../../scripts/version-update.js"
|
|
18
27
|
},
|
|
19
28
|
"keywords": [
|
|
20
29
|
"instrumentation",
|
|
@@ -43,12 +52,13 @@
|
|
|
43
52
|
"devDependencies": {
|
|
44
53
|
"@opentelemetry/api": "^1.3.0",
|
|
45
54
|
"@opentelemetry/context-async-hooks": "^2.0.0",
|
|
46
|
-
"@opentelemetry/contrib-test-utils": "^0.
|
|
55
|
+
"@opentelemetry/contrib-test-utils": "^0.50.0",
|
|
47
56
|
"@opentelemetry/sdk-metrics": "^2.0.0",
|
|
48
57
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
49
58
|
"@types/mocha": "10.0.10",
|
|
50
59
|
"@types/node": "18.18.14",
|
|
51
60
|
"@types/sinon": "17.0.4",
|
|
61
|
+
"cross-env": "7.0.3",
|
|
52
62
|
"mysql": "2.18.1",
|
|
53
63
|
"nyc": "17.1.0",
|
|
54
64
|
"rimraf": "5.0.10",
|
|
@@ -56,10 +66,10 @@
|
|
|
56
66
|
"typescript": "5.0.4"
|
|
57
67
|
},
|
|
58
68
|
"dependencies": {
|
|
59
|
-
"@opentelemetry/instrumentation": "^0.
|
|
69
|
+
"@opentelemetry/instrumentation": "^0.204.0",
|
|
60
70
|
"@opentelemetry/semantic-conventions": "^1.27.0",
|
|
61
71
|
"@types/mysql": "2.15.27"
|
|
62
72
|
},
|
|
63
|
-
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/
|
|
64
|
-
"gitHead": "
|
|
73
|
+
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-mysql#readme",
|
|
74
|
+
"gitHead": "0a45ac1b951d2acd2e40834e7ae012c04820faec"
|
|
65
75
|
}
|