Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update mysql instr name
  • Loading branch information
dyladan committed Mar 23, 2021
commit 8f8485a3d238ef3ae4f3f868fbb99bce0d07fdb2
4 changes: 2 additions & 2 deletions metapackages/auto-instrumentations-node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';
import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa';
import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb';
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
import { MysqlInstrumentation } from '@opentelemetry/instrumentation-mysql';
import { MySQLInstrumentation } from '@opentelemetry/instrumentation-mysql';
import { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';

const InstrumentationMap = {
Expand All @@ -38,7 +38,7 @@ const InstrumentationMap = {
'@opentelemetry/instrumentation-ioredis': IORedisInstrumentation,
'@opentelemetry/instrumentation-mongodb': MongoDBInstrumentation,
'@opentelemetry/instrumentation-pg': PgInstrumentation,
'@opentelemetry/instrumentation-mysql': MysqlInstrumentation,
'@opentelemetry/instrumentation-mysql': MySQLInstrumentation,
'@opentelemetry/instrumentation-redis': RedisInstrumentation,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('utils', () => {
'@opentelemetry/instrumentation-pg',
'@opentelemetry/instrumentation-redis',
];
assert.strictEqual(instrumentations.length, 10);
assert.strictEqual(instrumentations.length, 11);
for (let i = 0, j = instrumentations.length; i < j; i++) {
assert.strictEqual(
instrumentations[i].instrumentationName,
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-instrumentation-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OpenTelemetry MySQL Instrumentation allows the user to automatically collect tra
To load a specific plugin (**MySQL** in this case), specify it in the registerInstrumentations's configuration
```js
const { NodeTracerProvider } = require('@opentelemetry/node');
const { MysqlInstrumentation } = require('@opentelemetry/instrumentation-mysql');
const { MySQLInstrumentation } = require('@opentelemetry/instrumentation-mysql');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
Expand All @@ -33,7 +33,7 @@ provider.register();

registerInstrumentations({
instrumentations: [
new MysqlInstrumentation(),
new MySQLInstrumentation(),
{
// be sure to disable old plugin but only if it was installed
plugins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

export * from './mysql';
export { MysqlInstrumentationConfig } from './types';
export { MySQLInstrumentationConfig } from './types';
20 changes: 10 additions & 10 deletions plugins/node/opentelemetry-instrumentation-mysql/src/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ import {
} from '@opentelemetry/instrumentation';
import { DatabaseAttribute } from '@opentelemetry/semantic-conventions';
import type * as mysqlTypes from 'mysql';
import { MysqlInstrumentationConfig } from './types';
import { MySQLInstrumentationConfig } from './types';
import { getConnectionAttributes, getDbStatement, getSpanName } from './utils';
import { VERSION } from './version';

type formatType = typeof mysqlTypes.format;

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

constructor(protected _config: MysqlInstrumentationConfig = {}) {
constructor(protected _config: MySQLInstrumentationConfig = {}) {
super('@opentelemetry/instrumentation-mysql', VERSION, _config);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
private _patchCreateConnection(format: formatType) {
return (originalCreateConnection: Function) => {
const thisPlugin = this;
diag.debug('MysqlInstrumentation#patch: patched mysql createConnection');
diag.debug('MySQLInstrumentation#patch: patched mysql createConnection');

return function createConnection(
_connectionUri: string | mysqlTypes.ConnectionConfig
Expand All @@ -117,7 +117,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
private _patchCreatePool(format: formatType) {
return (originalCreatePool: Function) => {
const thisPlugin = this;
diag.debug('MysqlInstrumentation#patch: patched mysql createPool');
diag.debug('MySQLInstrumentation#patch: patched mysql createPool');
return function createPool(_config: string | mysqlTypes.PoolConfig) {
const pool = originalCreatePool(...arguments);

Expand All @@ -137,7 +137,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
private _patchCreatePoolCluster(format: formatType) {
return (originalCreatePoolCluster: Function) => {
const thisPlugin = this;
diag.debug('MysqlInstrumentation#patch: patched mysql createPoolCluster');
diag.debug('MySQLInstrumentation#patch: patched mysql createPoolCluster');
return function createPool(_config: string | mysqlTypes.PoolConfig) {
const cluster = originalCreatePoolCluster(...arguments);

Expand All @@ -161,7 +161,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
return (originalGetConnection: Function) => {
const thisPlugin = this;
diag.debug(
'MysqlInstrumentation#patch: patched mysql pool getConnection'
'MySQLInstrumentation#patch: patched mysql pool getConnection'
);
return function getConnection(
arg1?: unknown,
Expand Down Expand Up @@ -227,7 +227,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
) {
return (originalQuery: Function): mysqlTypes.QueryFunction => {
const thisPlugin = this;
diag.debug('MysqlInstrumentation: patched mysql query');
diag.debug('MySQLInstrumentation: patched mysql query');

return function query(
query: string | mysqlTypes.Query | mysqlTypes.QueryOptions,
Expand All @@ -242,7 +242,7 @@ export class MysqlInstrumentation extends InstrumentationBase<
const span = thisPlugin.tracer.startSpan(getSpanName(query), {
kind: SpanKind.CLIENT,
attributes: {
...MysqlInstrumentation.COMMON_ATTRIBUTES,
...MySQLInstrumentation.COMMON_ATTRIBUTES,
...getConnectionAttributes(connection.config),
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

import { InstrumentationConfig } from '@opentelemetry/instrumentation';

export type MysqlInstrumentationConfig = InstrumentationConfig;
export type MySQLInstrumentationConfig = InstrumentationConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
import * as assert from 'assert';
import { MysqlInstrumentation } from '../src';
import { MySQLInstrumentation } from '../src';

const port = Number(process.env.MYSQL_PORT) || 33306;
const database = process.env.MYSQL_DATABASE || 'test_db';
const host = process.env.MYSQL_HOST || '127.0.0.1';
const user = process.env.MYSQL_USER || 'otel';
const password = process.env.MYSQL_PASSWORD || 'secret';

const instrumentation = new MysqlInstrumentation();
const instrumentation = new MySQLInstrumentation();
instrumentation.enable();
instrumentation.disable();

Expand Down