Skip to content

Commit

Permalink
docs: fix docs to reflect that it's for mysql2 package
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 committed Jun 4, 2021
1 parent 2a66655 commit f703b66
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
26 changes: 12 additions & 14 deletions plugins/node/opentelemetry-instrumentation-mysql2/README.md
Expand Up @@ -5,15 +5,15 @@
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

This module provides automatic instrumentation for [`mysql`](https://www.npmjs.com/package/mysql).
This module provides automatic instrumentation for [`mysql2`](https://github.com/sidorares/node-mysql2).

For automatic instrumentation see the
[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package.

## Installation

```bash
npm install --save @opentelemetry/instrumentation-mysql
npm install --save @opentelemetry/instrumentation-mysql2
```

## Supported Versions
Expand All @@ -22,27 +22,25 @@ npm install --save @opentelemetry/instrumentation-mysql

## Usage

OpenTelemetry MySQL Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [mysql](https://www.npmjs.com/package/mysql).
OpenTelemetry MySQL2 Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [mysql2](https://github.com/sidorares/node-mysql2).

To load a specific plugin (**MySQL** in this case), specify it in the registerInstrumentations's configuration
To load a specific plugin (**MySQL2** in this case), specify it in the registerInstrumentations's configuration

```js
const { NodeTracerProvider } = require('@opentelemetry/node');
const { MySQLInstrumentation } = require('@opentelemetry/instrumentation-mysql');
const { MySQL2Instrumentation } = require('@opentelemetry/instrumentation-mysql2');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
instrumentations: [
new MySQLInstrumentation(),
new MySQL2Instrumentation(),
],
})
```

See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/mysql) for a short example.

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand All @@ -56,9 +54,9 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-mysql
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-mysql.svg
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql2
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql2
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql2&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fnode%2Fopentelemetry-instrumentation-mysql2&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-mysql2
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-mysql2.svg
@@ -1,7 +1,7 @@
{
"name": "@opentelemetry/instrumentation-mysql2",
"version": "0.20.0",
"description": "OpenTelemetry mysql automatic instrumentation package.",
"description": "OpenTelemetry mysql2 automatic instrumentation package.",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js-contrib",
Expand All @@ -20,6 +20,7 @@
"keywords": [
"opentelemetry",
"mysql",
"mysql2",
"nodejs",
"tracing",
"profiling",
Expand Down
Expand Up @@ -14,5 +14,9 @@
* limitations under the License.
*/

import { MySQL2Instrumentation } from './instrumentation';

export * from './instrumentation';
export default MySQL2Instrumentation;

export { MySQL2InstrumentationConfig } from './types';
Expand Up @@ -33,12 +33,12 @@ import { VERSION } from './version';

type formatType = typeof mysqlTypes.format;

export class MySQLInstrumentation extends InstrumentationBase<
export class MySQL2Instrumentation extends InstrumentationBase<
typeof mysqlTypes
> {
static readonly COMPONENT = 'mysql';
static readonly COMMON_ATTRIBUTES = {
[SemanticAttributes.DB_SYSTEM]: MySQLInstrumentation.COMPONENT,
[SemanticAttributes.DB_SYSTEM]: MySQL2Instrumentation.COMPONENT,
};

constructor(protected _config: MySQL2InstrumentationConfig = {}) {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class MySQLInstrumentation extends InstrumentationBase<
private _patchQuery(format: formatType) {
return (originalQuery: Function): Function => {
const thisPlugin = this;
api.diag.debug('MySQLInstrumentation: patched mysql query');
api.diag.debug('MySQL2Instrumentation: patched mysql query');

return function query(
this: mysqlTypes.Connection,
Expand All @@ -98,7 +98,7 @@ export class MySQLInstrumentation extends InstrumentationBase<
const span = thisPlugin.tracer.startSpan(getSpanName(query), {
kind: api.SpanKind.CLIENT,
attributes: {
...MySQLInstrumentation.COMMON_ATTRIBUTES,
...MySQL2Instrumentation.COMMON_ATTRIBUTES,
...getConnectionAttributes(this.config),
[SemanticAttributes.DB_STATEMENT]: getDbStatement(
query,
Expand Down

0 comments on commit f703b66

Please sign in to comment.