@opentelemetry/instrumentation-cassandra-driver 0.58.0 → 0.60.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,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.CassandraDriverInstrumentation = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qDAAmE;AAA1D,iIAAA,8BAA8B,OAAA","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\nexport { CassandraDriverInstrumentation } from './instrumentation';\nexport type {\n CassandraDriverInstrumentationConfig,\n CassandraDriverResponseCustomAttributeFunction,\n ResponseHookInfo,\n ResultSet,\n Row,\n} from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAAmE;AAA1D,iIAAA,8BAA8B,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { CassandraDriverInstrumentation } from './instrumentation';\nexport type {\n CassandraDriverInstrumentationConfig,\n CassandraDriverResponseCustomAttributeFunction,\n ResponseHookInfo,\n ResultSet,\n Row,\n} from './types';\n"]}
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.CassandraDriverInstrumentation = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAO4B;AAC5B,oEAQwC;AAExC,uCASmB;AACnB,8EAM6C;AAC7C,kBAAkB;AAClB,uCAA0D;AAI1D,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAa,8BAA+B,SAAQ,qCAAyD;IACnG,oBAAoB,CAAoB;IACxC,mBAAmB,CAAoB;IAE/C,YAAY,SAA+C,EAAE;QAC3D,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACrC,CAAC;IAEO,2BAA2B;QACjC,IAAI,CAAC,oBAAoB,GA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CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AACpD,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\nimport {\n context,\n trace,\n Span,\n Attributes,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { CassandraDriverInstrumentationConfig, ResultSet } from './types';\nimport {\n DB_SYSTEM_VALUE_CASSANDRA,\n ATTR_DB_NAME,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n DB_SYSTEM_NAME_VALUE_CASSANDRA,\n} from './semconv';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { EventEmitter } from 'events';\nimport type * as CassandraDriver from 'cassandra-driver';\n\nconst supportedVersions = ['>=4.4.0 <5'];\n\nexport class CassandraDriverInstrumentation extends InstrumentationBase<CassandraDriverInstrumentationConfig> {\n private _netSemconvStability!: SemconvStability;\n private _dbSemconvStability!: SemconvStability;\n\n constructor(config: CassandraDriverInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this._setSemconvStabilityFromEnv();\n }\n\n private _setSemconvStabilityFromEnv() {\n this._netSemconvStability = semconvStabilityFromStr(\n 'http',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n this._dbSemconvStability = semconvStabilityFromStr(\n 'database',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n protected init() {\n return new InstrumentationNodeModuleDefinition(\n 'cassandra-driver',\n supportedVersions,\n driverModule => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Client = driverModule.Client.prototype as any;\n\n if (isWrapped(Client['_execute'])) {\n this._unwrap(Client, '_execute');\n }\n\n if (isWrapped(Client.batch)) {\n this._unwrap(Client, 'batch');\n }\n\n if (isWrapped(Client.stream)) {\n this._unwrap(Client, 'stream');\n }\n\n this._wrap(Client, '_execute', this._getPatchedExecute());\n this._wrap(Client, 'batch', this._getPatchedBatch());\n this._wrap(Client, 'stream', this._getPatchedStream());\n\n return driverModule;\n },\n driverModule => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Client = driverModule.Client.prototype as any;\n\n if (isWrapped(Client['_execute'])) {\n this._unwrap(Client, '_execute');\n }\n\n if (isWrapped(Client.batch)) {\n this._unwrap(Client, 'batch');\n }\n\n if (isWrapped(Client.stream)) {\n this._unwrap(Client, 'stream');\n }\n },\n [\n new InstrumentationNodeModuleFile(\n 'cassandra-driver/lib/request-execution.js',\n supportedVersions,\n execution => {\n if (isWrapped(execution.prototype['_sendOnConnection'])) {\n this._unwrap(execution.prototype, '_sendOnConnection');\n }\n\n this._wrap(\n execution.prototype,\n '_sendOnConnection',\n this._getPatchedSendOnConnection()\n );\n return execution;\n },\n execution => {\n if (execution === undefined) return;\n this._unwrap(execution.prototype, '_sendOnConnection');\n }\n ),\n ]\n );\n }\n\n private _getMaxQueryLength(): number {\n return this.getConfig().maxQueryLength ?? 65536;\n }\n\n private _shouldIncludeDbStatement(): boolean {\n return this.getConfig().enhancedDatabaseReporting ?? false;\n }\n\n private _getPatchedExecute() {\n return (\n original: (...args: unknown[]) => Promise<CassandraDriver.types.ResultSet>\n ) => {\n const plugin = this;\n return function patchedExecute(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n const span = plugin.startSpan({ op: 'execute', query: args[0] }, this);\n\n const execContext = trace.setSpan(context.active(), span);\n const execPromise = safeExecuteInTheMiddle(\n () => {\n return context.with(execContext, () => {\n return original.apply(this, args);\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n\n const wrappedPromise = wrapPromise(\n span,\n execPromise,\n (span, result) => {\n plugin._callResponseHook(span, result);\n }\n );\n\n return context.bind(execContext, wrappedPromise);\n };\n };\n }\n\n private _getPatchedSendOnConnection() {\n return (original: (...args: unknown[]) => unknown) => {\n const plugin = this;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function patchedSendOnConnection(this: any, ...args: unknown[]) {\n const span = trace.getSpan(context.active());\n const conn = this['_connection'];\n\n if (span !== undefined && conn !== undefined) {\n const port = parseInt(conn.port, 10);\n\n if (plugin._netSemconvStability & SemconvStability.OLD) {\n span.setAttribute(ATTR_NET_PEER_NAME, conn.address);\n if (!isNaN(port)) {\n span.setAttribute(ATTR_NET_PEER_PORT, port);\n }\n }\n if (plugin._netSemconvStability & SemconvStability.STABLE) {\n span.setAttribute(ATTR_SERVER_ADDRESS, conn.address);\n if (!isNaN(port)) {\n span.setAttribute(ATTR_SERVER_PORT, port);\n }\n }\n }\n\n return original.apply(this, args);\n };\n };\n }\n\n private _getPatchedBatch() {\n return (original: (...args: unknown[]) => unknown) => {\n const plugin = this;\n return function patchedBatch(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n const queries = Array.isArray(args[0]) ? args[0] : [];\n const span = plugin.startSpan(\n { op: 'batch', query: combineQueries(queries) },\n this\n );\n\n const batchContext = trace.setSpan(context.active(), span);\n\n if (typeof args[args.length - 1] === 'function') {\n const originalCallback = args[\n args.length - 1\n ] as CassandraDriver.ValueCallback<CassandraDriver.types.ResultSet>;\n\n const patchedCallback = function (\n this: unknown,\n ...cbArgs: Parameters<typeof originalCallback>\n ) {\n const error = cbArgs[0];\n\n if (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n }\n\n span.end();\n\n return originalCallback.apply(this, cbArgs);\n };\n\n args[args.length - 1] = patchedCallback;\n\n return context.with(batchContext, () => {\n return original.apply(this, args);\n });\n }\n\n const batchPromise = safeExecuteInTheMiddle(\n () => {\n return context.with(batchContext, () => {\n return original.apply(\n this,\n args\n ) as Promise<CassandraDriver.types.ResultSet>;\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n\n const wrappedPromise = wrapPromise(span, batchPromise);\n\n return context.bind(batchContext, wrappedPromise);\n };\n };\n }\n\n private _getPatchedStream() {\n return (original: (...args: unknown[]) => EventEmitter) => {\n const plugin = this;\n return function patchedStream(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n // Since stream internally uses execute, there is no need to add DB_STATEMENT twice\n const span = plugin.startSpan({ op: 'stream' }, this);\n\n const callback = args[3];\n\n const endSpan = (error: Error) => {\n if (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n }\n span.end();\n };\n\n if (callback === undefined) {\n args[3] = endSpan;\n } else if (typeof callback === 'function') {\n const wrappedCallback = function (this: unknown, err: Error) {\n endSpan(err);\n return callback.call(this, err);\n };\n args[3] = wrappedCallback;\n }\n const streamContext = trace.setSpan(context.active(), span);\n return safeExecuteInTheMiddle(\n () => {\n return context.with(streamContext, () => {\n return original.apply(this, args);\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n };\n };\n }\n\n private startSpan(\n { op, query }: { op: string; query?: unknown },\n client: CassandraDriver.Client\n ): Span {\n const attributes: Attributes = {};\n\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_CASSANDRA;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_CASSANDRA;\n }\n\n if (this._shouldIncludeDbStatement() && query !== undefined) {\n const statement = truncateQuery(query, this._getMaxQueryLength());\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_STATEMENT] = statement;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_QUERY_TEXT] = statement;\n }\n }\n\n // db.user (deprecated, no stable replacement - only emit with OLD)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const user = (client as any).options?.credentials?.username;\n if (user && this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_USER] = user;\n }\n\n if (client.keyspace) {\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_NAME] = client.keyspace;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_NAMESPACE] = client.keyspace;\n }\n }\n\n return this.tracer.startSpan(`cassandra-driver.${op}`, {\n kind: SpanKind.CLIENT,\n attributes,\n });\n }\n\n private _callResponseHook(span: Span, response: ResultSet) {\n const { responseHook } = this.getConfig();\n if (!responseHook) {\n return;\n }\n\n safeExecuteInTheMiddle(\n () => responseHook(span, { response: response }),\n e => {\n if (e) {\n this._diag.error('responseHook error', e);\n }\n },\n true\n );\n }\n}\n\nfunction failSpan(span: Span, error: Error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n span.end();\n}\n\nfunction combineQueries(queries: Array<string | { query: string }>) {\n return queries\n .map(query => (typeof query === 'string' ? query : query.query))\n .join('\\n');\n}\n\nfunction wrapPromise<T>(\n span: Span,\n promise: Promise<T>,\n successCallback?: (span: Span, result: T) => void\n): Promise<T> {\n return promise\n .then(result => {\n return new Promise<T>(resolve => {\n if (successCallback) {\n successCallback(span, result);\n }\n span.end();\n resolve(result);\n });\n })\n .catch((error: Error) => {\n return new Promise<T>((_, reject) => {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n span.end();\n reject(error);\n });\n });\n}\n\nfunction truncateQuery(query: unknown, maxQueryLength: number) {\n return String(query).substring(0, maxQueryLength);\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAO4B;AAC5B,oEAQwC;AAExC,uCASmB;AACnB,8EAM6C;AAC7C,kBAAkB;AAClB,uCAA0D;AAI1D,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAa,8BAA+B,SAAQ,qCAAyD;IACnG,oBAAoB,CAAoB;IACxC,mBAAmB,CAAoB;IAE/C,YAAY,SAA+C,EAAE;QAC3D,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACrC,CAAC;IAEO,2BAA2B;QACjC,IAAI,CAAC,oBAAoB,GAAG,IAAA,yCAAuB,EACjD,MAAM,EACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC1C,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAA,yCAAuB,EAChD,UAAU,EACV,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC1C,CAAC;IACJ,CAAC;IAES,IAAI;QACZ,OAAO,IAAI,qDAAmC,CAC5C,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,CAAC,EAAE;YACb,8DAA8D;YAC9D,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,SAAgB,CAAC;YAEpD,IAAI,IAAA,2BAAS,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE;gBACjC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;aAClC;YAED,IAAI,IAAA,2BAAS,EAA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C,EAAE;YAC9B,IAAI,eAAe,EAAE;gBACnB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;aAC/B;YACD,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;QACtB,OAAO,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAClC,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,oBAAc,CAAC,KAAK;gBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAC;YACH,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,cAAsB;IAC3D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n context,\n trace,\n Span,\n Attributes,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { CassandraDriverInstrumentationConfig, ResultSet } from './types';\nimport {\n DB_SYSTEM_VALUE_CASSANDRA,\n ATTR_DB_NAME,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_DB_USER,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n DB_SYSTEM_NAME_VALUE_CASSANDRA,\n} from './semconv';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { EventEmitter } from 'events';\nimport type * as CassandraDriver from 'cassandra-driver';\n\nconst supportedVersions = ['>=4.4.0 <5'];\n\nexport class CassandraDriverInstrumentation extends InstrumentationBase<CassandraDriverInstrumentationConfig> {\n private _netSemconvStability!: SemconvStability;\n private _dbSemconvStability!: SemconvStability;\n\n constructor(config: CassandraDriverInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n this._setSemconvStabilityFromEnv();\n }\n\n private _setSemconvStabilityFromEnv() {\n this._netSemconvStability = semconvStabilityFromStr(\n 'http',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n this._dbSemconvStability = semconvStabilityFromStr(\n 'database',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n protected init() {\n return new InstrumentationNodeModuleDefinition(\n 'cassandra-driver',\n supportedVersions,\n driverModule => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Client = driverModule.Client.prototype as any;\n\n if (isWrapped(Client['_execute'])) {\n this._unwrap(Client, '_execute');\n }\n\n if (isWrapped(Client.batch)) {\n this._unwrap(Client, 'batch');\n }\n\n if (isWrapped(Client.stream)) {\n this._unwrap(Client, 'stream');\n }\n\n this._wrap(Client, '_execute', this._getPatchedExecute());\n this._wrap(Client, 'batch', this._getPatchedBatch());\n this._wrap(Client, 'stream', this._getPatchedStream());\n\n return driverModule;\n },\n driverModule => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Client = driverModule.Client.prototype as any;\n\n if (isWrapped(Client['_execute'])) {\n this._unwrap(Client, '_execute');\n }\n\n if (isWrapped(Client.batch)) {\n this._unwrap(Client, 'batch');\n }\n\n if (isWrapped(Client.stream)) {\n this._unwrap(Client, 'stream');\n }\n },\n [\n new InstrumentationNodeModuleFile(\n 'cassandra-driver/lib/request-execution.js',\n supportedVersions,\n execution => {\n if (isWrapped(execution.prototype['_sendOnConnection'])) {\n this._unwrap(execution.prototype, '_sendOnConnection');\n }\n\n this._wrap(\n execution.prototype,\n '_sendOnConnection',\n this._getPatchedSendOnConnection()\n );\n return execution;\n },\n execution => {\n if (execution === undefined) return;\n this._unwrap(execution.prototype, '_sendOnConnection');\n }\n ),\n ]\n );\n }\n\n private _getMaxQueryLength(): number {\n return this.getConfig().maxQueryLength ?? 65536;\n }\n\n private _shouldIncludeDbStatement(): boolean {\n return this.getConfig().enhancedDatabaseReporting ?? false;\n }\n\n private _getPatchedExecute() {\n return (\n original: (...args: unknown[]) => Promise<CassandraDriver.types.ResultSet>\n ) => {\n const plugin = this;\n return function patchedExecute(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n const span = plugin.startSpan({ op: 'execute', query: args[0] }, this);\n\n const execContext = trace.setSpan(context.active(), span);\n const execPromise = safeExecuteInTheMiddle(\n () => {\n return context.with(execContext, () => {\n return original.apply(this, args);\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n\n const wrappedPromise = wrapPromise(\n span,\n execPromise,\n (span, result) => {\n plugin._callResponseHook(span, result);\n }\n );\n\n return context.bind(execContext, wrappedPromise);\n };\n };\n }\n\n private _getPatchedSendOnConnection() {\n return (original: (...args: unknown[]) => unknown) => {\n const plugin = this;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function patchedSendOnConnection(this: any, ...args: unknown[]) {\n const span = trace.getSpan(context.active());\n const conn = this['_connection'];\n\n if (span !== undefined && conn !== undefined) {\n const port = parseInt(conn.port, 10);\n\n if (plugin._netSemconvStability & SemconvStability.OLD) {\n span.setAttribute(ATTR_NET_PEER_NAME, conn.address);\n if (!isNaN(port)) {\n span.setAttribute(ATTR_NET_PEER_PORT, port);\n }\n }\n if (plugin._netSemconvStability & SemconvStability.STABLE) {\n span.setAttribute(ATTR_SERVER_ADDRESS, conn.address);\n if (!isNaN(port)) {\n span.setAttribute(ATTR_SERVER_PORT, port);\n }\n }\n }\n\n return original.apply(this, args);\n };\n };\n }\n\n private _getPatchedBatch() {\n return (original: (...args: unknown[]) => unknown) => {\n const plugin = this;\n return function patchedBatch(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n const queries = Array.isArray(args[0]) ? args[0] : [];\n const span = plugin.startSpan(\n { op: 'batch', query: combineQueries(queries) },\n this\n );\n\n const batchContext = trace.setSpan(context.active(), span);\n\n if (typeof args[args.length - 1] === 'function') {\n const originalCallback = args[\n args.length - 1\n ] as CassandraDriver.ValueCallback<CassandraDriver.types.ResultSet>;\n\n const patchedCallback = function (\n this: unknown,\n ...cbArgs: Parameters<typeof originalCallback>\n ) {\n const error = cbArgs[0];\n\n if (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n }\n\n span.end();\n\n return originalCallback.apply(this, cbArgs);\n };\n\n args[args.length - 1] = patchedCallback;\n\n return context.with(batchContext, () => {\n return original.apply(this, args);\n });\n }\n\n const batchPromise = safeExecuteInTheMiddle(\n () => {\n return context.with(batchContext, () => {\n return original.apply(\n this,\n args\n ) as Promise<CassandraDriver.types.ResultSet>;\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n\n const wrappedPromise = wrapPromise(span, batchPromise);\n\n return context.bind(batchContext, wrappedPromise);\n };\n };\n }\n\n private _getPatchedStream() {\n return (original: (...args: unknown[]) => EventEmitter) => {\n const plugin = this;\n return function patchedStream(\n this: CassandraDriver.Client,\n ...args: unknown[]\n ) {\n // Since stream internally uses execute, there is no need to add DB_STATEMENT twice\n const span = plugin.startSpan({ op: 'stream' }, this);\n\n const callback = args[3];\n\n const endSpan = (error: Error) => {\n if (error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n }\n span.end();\n };\n\n if (callback === undefined) {\n args[3] = endSpan;\n } else if (typeof callback === 'function') {\n const wrappedCallback = function (this: unknown, err: Error) {\n endSpan(err);\n return callback.call(this, err);\n };\n args[3] = wrappedCallback;\n }\n const streamContext = trace.setSpan(context.active(), span);\n return safeExecuteInTheMiddle(\n () => {\n return context.with(streamContext, () => {\n return original.apply(this, args);\n });\n },\n error => {\n if (error) {\n failSpan(span, error);\n }\n }\n );\n };\n };\n }\n\n private startSpan(\n { op, query }: { op: string; query?: unknown },\n client: CassandraDriver.Client\n ): Span {\n const attributes: Attributes = {};\n\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_CASSANDRA;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_CASSANDRA;\n }\n\n if (this._shouldIncludeDbStatement() && query !== undefined) {\n const statement = truncateQuery(query, this._getMaxQueryLength());\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_STATEMENT] = statement;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_QUERY_TEXT] = statement;\n }\n }\n\n // db.user (deprecated, no stable replacement - only emit with OLD)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const user = (client as any).options?.credentials?.username;\n if (user && this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_USER] = user;\n }\n\n if (client.keyspace) {\n if (this._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_NAME] = client.keyspace;\n }\n if (this._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_NAMESPACE] = client.keyspace;\n }\n }\n\n return this.tracer.startSpan(`cassandra-driver.${op}`, {\n kind: SpanKind.CLIENT,\n attributes,\n });\n }\n\n private _callResponseHook(span: Span, response: ResultSet) {\n const { responseHook } = this.getConfig();\n if (!responseHook) {\n return;\n }\n\n safeExecuteInTheMiddle(\n () => responseHook(span, { response: response }),\n e => {\n if (e) {\n this._diag.error('responseHook error', e);\n }\n },\n true\n );\n }\n}\n\nfunction failSpan(span: Span, error: Error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n span.end();\n}\n\nfunction combineQueries(queries: Array<string | { query: string }>) {\n return queries\n .map(query => (typeof query === 'string' ? query : query.query))\n .join('\\n');\n}\n\nfunction wrapPromise<T>(\n span: Span,\n promise: Promise<T>,\n successCallback?: (span: Span, result: T) => void\n): Promise<T> {\n return promise\n .then(result => {\n return new Promise<T>(resolve => {\n if (successCallback) {\n successCallback(span, result);\n }\n span.end();\n resolve(result);\n });\n })\n .catch((error: Error) => {\n return new Promise<T>((_, reject) => {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.recordException(error);\n span.end();\n reject(error);\n });\n });\n}\n\nfunction truncateQuery(query: unknown, maxQueryLength: number) {\n return String(query).substring(0, maxQueryLength);\n}\n"]}
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.DB_SYSTEM_NAME_VALUE_CASSANDRA = exports.DB_SYSTEM_VALUE_CASSANDRA = exports.ATTR_NET_PEER_PORT = exports.ATTR_NET_PEER_NAME = exports.ATTR_DB_USER = exports.ATTR_DB_SYSTEM = exports.ATTR_DB_STATEMENT = exports.ATTR_DB_NAME = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;GAMG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,WAAoB,CAAC;AAE9D;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAG,WAAoB,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/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @example customers\n * @example main\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * Deprecated, no replacement at this time.\n *\n * @example readonly_user\n * @example reporting_user\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Removed, no replacement at this time.\n */\nexport const ATTR_DB_USER = 'db.user' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @example example.com\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @example 8080\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n\n/**\n * Enum value \"cassandra\" for attribute {@link ATTR_DB_SYSTEM}.\n *\n * Apache Cassandra\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_VALUE_CASSANDRA = 'cassandra' as const;\n\n/**\n * Enum value \"cassandra\" for attribute {@link ATTR_DB_SYSTEM_NAME}.\n *\n * [Apache Cassandra](https://cassandra.apache.org/)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_NAME_VALUE_CASSANDRA = 'cassandra' as const;\n"]}
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,cAAuB,CAAC;AAEzD;;;;;;GAMG;AACU,QAAA,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,WAAoB,CAAC;AAE9D;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAG,WAAoB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @example customers\n * @example main\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * Deprecated, no replacement at this time.\n *\n * @example readonly_user\n * @example reporting_user\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Removed, no replacement at this time.\n */\nexport const ATTR_DB_USER = 'db.user' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @example example.com\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @example 8080\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n\n/**\n * Enum value \"cassandra\" for attribute {@link ATTR_DB_SYSTEM}.\n *\n * Apache Cassandra\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_VALUE_CASSANDRA = 'cassandra' as const;\n\n/**\n * Enum value \"cassandra\" for attribute {@link ATTR_DB_SYSTEM_NAME}.\n *\n * [Apache Cassandra](https://cassandra.apache.org/)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_NAME_VALUE_CASSANDRA = 'cassandra' as const;\n"]}
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { Span } from '@opentelemetry/api';\n\nexport interface Row {\n get(columnName: string | number): any;\n\n keys(): string[];\n\n forEach(callback: (row: Row) => void): void;\n\n values(): any[];\n\n [key: string]: any;\n}\n\n// https://github.com/datastax/nodejs-driver/blob/d42176e4baa1cfc3df79699cc3b5d575c86e3cec/lib/types/index.d.ts#L323\nexport interface ResultSet {\n rows: Row[];\n}\n\nexport interface ResponseHookInfo {\n response: ResultSet;\n}\n\nexport interface CassandraDriverResponseCustomAttributeFunction {\n (span: Span, responseInfo: ResponseHookInfo): void;\n}\n\nexport interface CassandraDriverInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * Include database statements with spans.\n * These can contain sensitive information when using unescaped queries.\n * @default false\n */\n enhancedDatabaseReporting?: boolean;\n /**\n * Max recorded query length.\n * @default 65536\n */\n maxQueryLength?: number;\n /**\n * Function for adding custom attributes before response is handled.\n * @param span the current span\n * @param responseInfo array of the resulting rows. This will only return the first page of results\n */\n responseHook?: CassandraDriverResponseCustomAttributeFunction;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { Span } from '@opentelemetry/api';\n\nexport interface Row {\n get(columnName: string | number): any;\n\n keys(): string[];\n\n forEach(callback: (row: Row) => void): void;\n\n values(): any[];\n\n [key: string]: any;\n}\n\n// https://github.com/datastax/nodejs-driver/blob/d42176e4baa1cfc3df79699cc3b5d575c86e3cec/lib/types/index.d.ts#L323\nexport interface ResultSet {\n rows: Row[];\n}\n\nexport interface ResponseHookInfo {\n response: ResultSet;\n}\n\nexport interface CassandraDriverResponseCustomAttributeFunction {\n (span: Span, responseInfo: ResponseHookInfo): void;\n}\n\nexport interface CassandraDriverInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * Include database statements with spans.\n * These can contain sensitive information when using unescaped queries.\n * @default false\n */\n enhancedDatabaseReporting?: boolean;\n /**\n * Max recorded query length.\n * @default 65536\n */\n maxQueryLength?: number;\n /**\n * Function for adding custom attributes before response is handled.\n * @param span the current span\n * @param responseInfo array of the resulting rows. This will only return the first page of results\n */\n responseHook?: CassandraDriverResponseCustomAttributeFunction;\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.58.0";
1
+ export declare const PACKAGE_VERSION = "0.60.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-cassandra-driver";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,22 +1,11 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
8
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.58.0';
9
+ exports.PACKAGE_VERSION = '0.60.0';
21
10
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-cassandra-driver';
22
11
  //# sourceMappingURL=version.js.map
@@ -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,iDAAiD,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.58.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-cassandra-driver';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,iDAAiD,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.60.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-cassandra-driver';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-cassandra-driver",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "description": "OpenTelemetry instrumentation for `cassandra-driver` database client library for Apache Cassandra",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -53,15 +53,15 @@
53
53
  "devDependencies": {
54
54
  "@opentelemetry/api": "^1.3.0",
55
55
  "@opentelemetry/context-async-hooks": "^2.0.0",
56
- "@opentelemetry/contrib-test-utils": "^0.60.0",
56
+ "@opentelemetry/contrib-test-utils": "^0.62.0",
57
57
  "@opentelemetry/sdk-trace-base": "^2.0.0",
58
58
  "@opentelemetry/sdk-trace-node": "^2.0.0",
59
59
  "cassandra-driver": "4.6.4"
60
60
  },
61
61
  "dependencies": {
62
- "@opentelemetry/instrumentation": "^0.213.0",
62
+ "@opentelemetry/instrumentation": "^0.215.0",
63
63
  "@opentelemetry/semantic-conventions": "^1.37.0"
64
64
  },
65
65
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-cassandra-driver#readme",
66
- "gitHead": "39f08c313dc4d929c110ab7c43771c3cdbf8aa4c"
66
+ "gitHead": "bd017c86bcdf369d7bc1b490e455f95b25385779"
67
67
  }