Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-mysql2

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-mysql2 - npm Package Compare versions

Comparing version 0.28.0 to 0.29.0

3

build/src/instrumentation.d.ts

@@ -5,5 +5,4 @@ import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';

export declare class MySQL2Instrumentation extends InstrumentationBase<typeof mysqlTypes> {
static readonly COMPONENT = "mysql";
static readonly COMMON_ATTRIBUTES: {
[x: string]: string;
[x: string]: "mysql";
};

@@ -10,0 +9,0 @@ constructor(config?: MySQL2InstrumentationConfig);

@@ -30,3 +30,3 @@ "use strict";

return [
new instrumentation_1.InstrumentationNodeModuleDefinition('mysql2', ['2.*'], (moduleExports, moduleVersion) => {
new instrumentation_1.InstrumentationNodeModuleDefinition('mysql2', ['>= 1.4.2 < 3.0'], (moduleExports, moduleVersion) => {
api.diag.debug(`Patching mysql@${moduleVersion}`);

@@ -64,3 +64,3 @@ const ConnectionPrototype = moduleExports.Connection.prototype;

});
const endSpan = utils_1.once((err) => {
const endSpan = utils_1.once((err, results) => {
if (err) {

@@ -72,2 +72,14 @@ span.setStatus({

}
else {
const config = thisPlugin._config;
if (typeof config.responseHook === 'function') {
instrumentation_1.safeExecuteInTheMiddle(() => {
config.responseHook(span, { queryResults: results });
}, err => {
if (err) {
thisPlugin._diag.warn('Failed executing responseHook', err);
}
}, true);
}
}
span.end();

@@ -85,4 +97,4 @@ });

})
.once('result', () => {
endSpan();
.once('result', results => {
endSpan(undefined, results);
});

@@ -104,3 +116,3 @@ return streamableQuery;

return function (err, results, fields) {
endSpan(err);
endSpan(err, results);
return originalCallback(...arguments);

@@ -112,6 +124,5 @@ };

exports.MySQL2Instrumentation = MySQL2Instrumentation;
MySQL2Instrumentation.COMPONENT = 'mysql';
MySQL2Instrumentation.COMMON_ATTRIBUTES = {
[semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: MySQL2Instrumentation.COMPONENT,
[semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.MYSQL,
};
//# sourceMappingURL=instrumentation.js.map
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
export declare type MySQL2InstrumentationConfig = InstrumentationConfig;
import type { Span } from '@opentelemetry/api';
export interface MySQL2ResponseHookInformation {
queryResults: any;
}
export interface MySQL2InstrumentationExecutionResponseHook {
(span: Span, responseHookInfo: MySQL2ResponseHookInformation): void;
}
export interface MySQL2InstrumentationConfig extends InstrumentationConfig {
/**
* Hook that allows adding custom span attributes based on the data
* returned MySQL2 queries.
*
* @default undefined
*/
responseHook?: MySQL2InstrumentationExecutionResponseHook;
}
//# sourceMappingURL=types.d.ts.map

@@ -30,3 +30,3 @@ "use strict";

[semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: port,
[semantic_conventions_1.SemanticAttributes.NET_PEER_IP]: getJDBCString(host, port, database),
[semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString(host, port, database),
[semantic_conventions_1.SemanticAttributes.DB_NAME]: database,

@@ -76,6 +76,6 @@ [semantic_conventions_1.SemanticAttributes.DB_USER]: user,

function getSpanName(query) {
if (typeof query === 'object') {
return query.sql;
}
return query.split(' ')[0];
var _a;
const rawQuery = typeof query === 'object' ? query.sql : query;
// Extract the SQL verb
return (_a = rawQuery === null || rawQuery === void 0 ? void 0 : rawQuery.split(' ')) === null || _a === void 0 ? void 0 : _a[0];
}

@@ -82,0 +82,0 @@ exports.getSpanName = getSpanName;

@@ -1,2 +0,2 @@

export declare const VERSION = "0.28.0";
export declare const VERSION = "0.29.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.28.0';
exports.VERSION = '0.29.0';
//# sourceMappingURL=version.js.map
# Changelog
## [0.29.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-mysql2-v0.28.0...instrumentation-mysql2-v0.29.0) (2022-03-02)
### ⚠ BREAKING CHANGES
* **mysql*,redis:** net.peer.ip -> db.connection_string
### Features
* add mysql2 responsehook ([#915](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/915)) ([f436601](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/f4366015e2a628efc4cb8a47d508ba5620175f88))
* support mysql2 v1 ([#908](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/908)) ([d3883d3](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/d3883d38b7cf929404cf4eac9a9a48b7d1f4327f))
### Bug Fixes
* **mysql*,redis:** net.peer.ip -> db.connection_string ([bf39b90](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/bf39b908fd64cec92c862b2deca5d760ddcf4509))
* use SQL verb for mysql2 span name when query object is used ([#923](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/923)) ([3d1388b](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/3d1388b0f779417de86b5b9af84d9000c7f67782))
## [0.28.0](https://www.github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-mysql2-v0.27.0...instrumentation-mysql2-v0.28.0) (2022-01-24)

@@ -50,2 +68,2 @@

* devDependencies
* @opentelemetry/contrib-test-utils bumped from ^0.25.0 to ^0.27.0
* @opentelemetry/contrib-test-utils bumped from ^0.25.0 to ^0.27.0
{
"name": "@opentelemetry/instrumentation-mysql2",
"version": "0.28.0",
"version": "0.29.0",
"description": "OpenTelemetry mysql2 automatic instrumentation package.",

@@ -10,3 +10,2 @@ "main": "build/src/index.js",

"clean": "rimraf build/*",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"compile": "npm run version:update && tsc -p .",

@@ -57,4 +56,5 @@ "lint:fix": "eslint . --ext .ts --fix",

"@types/mocha": "7.0.2",
"@types/node": "14.17.9",
"codecov": "3.8.3",
"@types/mysql2": "github:types/mysql2",
"@types/node": "16.11.21",
"@types/semver": "7.3.8",
"gts": "3.1.0",

@@ -65,2 +65,3 @@ "mocha": "7.2.0",

"rimraf": "3.0.2",
"semver": "7.3.5",
"test-all-versions": "5.0.1",

@@ -74,3 +75,3 @@ "ts-mocha": "8.0.0",

},
"gitHead": "edfc04cbe3e7faaa365724ddc26bf702b68cc008"
"gitHead": "78717b6dda677bf737811c34df21ef0ec88c31a3"
}

@@ -23,3 +23,3 @@ # OpenTelemetry mysql Instrumentation for Node.js

- `2.x`
- `>= 1.4.2, < 3.0`

@@ -47,2 +47,10 @@ ## Usage

### MySQL2 Instrumentation Options
You can set the following instrumentation options:
| Options | Type | Description |
| ------- | ---- | ----------- |
| `responseHook` | `MySQL2InstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response |
## Useful links

@@ -49,0 +57,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc