Skip to content

Commit

Permalink
refactor(instrumentation-amqplib): revert prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jan 9, 2023
1 parent b66d179 commit 3fcf648
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions plugins/node/instrumentation-amqplib/src/amqplib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,36 @@ import {
SpanKind,
SpanStatusCode,
ROOT_CONTEXT,
} from "@opentelemetry/api";
} from '@opentelemetry/api';
import {
hrTime,
hrTimeDuration,
hrTimeToMilliseconds,
} from "@opentelemetry/core";
} from '@opentelemetry/core';
import {
InstrumentationBase,
InstrumentationNodeModuleDefinition,
InstrumentationNodeModuleFile,
isWrapped,
safeExecuteInTheMiddle,
} from "@opentelemetry/instrumentation";
} from '@opentelemetry/instrumentation';
import {
SemanticAttributes,
MessagingOperationValues,
MessagingDestinationKindValues,
} from "@opentelemetry/semantic-conventions";
} from '@opentelemetry/semantic-conventions';
import {
Connection,
ConsumeMessage,
Message,
Options,
Replies,
} from "./internal-types";
} from './internal-types';
import {
AmqplibInstrumentationConfig,
DEFAULT_CONFIG,
EndOperation,
} from "./types";
} from './types';
import {
CHANNEL_CONSUME_TIMEOUT_TIMER,
CHANNEL_SPANS_NOT_ENDED,
Expand All @@ -66,15 +66,15 @@ import {
MESSAGE_STORED_SPAN,
normalizeExchange,
unmarkConfirmChannelTracing,
} from "./utils";
import { VERSION } from "./version";
} from './utils';
import { VERSION } from './version';

export class AmqplibInstrumentation extends InstrumentationBase {
protected override _config!: AmqplibInstrumentationConfig;

constructor(config?: AmqplibInstrumentationConfig) {
super(
"@opentelemetry/instrumentation-amqplib",
'@opentelemetry/instrumentation-amqplib',
VERSION,
Object.assign({}, DEFAULT_CONFIG, config)
);
Expand All @@ -86,29 +86,29 @@ export class AmqplibInstrumentation extends InstrumentationBase {

protected init() {
const channelModelModuleFile = new InstrumentationNodeModuleFile(
"amqplib/lib/channel_model.js",
[">=0.5.5"],
'amqplib/lib/channel_model.js',
['>=0.5.5'],
this.patchChannelModel.bind(this),
this.unpatchChannelModel.bind(this)
);

const callbackModelModuleFile = new InstrumentationNodeModuleFile(
"amqplib/lib/callback_model.js",
[">=0.5.5"],
'amqplib/lib/callback_model.js',
['>=0.5.5'],
this.patchChannelModel.bind(this),
this.unpatchChannelModel.bind(this)
);

const connectModuleFile = new InstrumentationNodeModuleFile(
"amqplib/lib/connect.js",
[">=0.5.5"],
'amqplib/lib/connect.js',
['>=0.5.5'],
this.patchConnect.bind(this),
this.unpatchConnect.bind(this)
);

const module = new InstrumentationNodeModuleDefinition(
"amqplib",
[">=0.5.5"],
'amqplib',
['>=0.5.5'],
undefined,
undefined,
[channelModelModuleFile, connectModuleFile, callbackModelModuleFile]
Expand All @@ -119,14 +119,14 @@ export class AmqplibInstrumentation extends InstrumentationBase {
private patchConnect(moduleExports: any) {
moduleExports = this.unpatchConnect(moduleExports);
if (!isWrapped(moduleExports.connect)) {
this._wrap(moduleExports, "connect", this.getConnectPatch.bind(this));
this._wrap(moduleExports, 'connect', this.getConnectPatch.bind(this));
}
return moduleExports;
}

private unpatchConnect(moduleExports: any) {
if (isWrapped(moduleExports.connect)) {
this._unwrap(moduleExports, "connect");
this._unwrap(moduleExports, 'connect');
}
return moduleExports;
}
Expand All @@ -138,63 +138,63 @@ export class AmqplibInstrumentation extends InstrumentationBase {
if (!isWrapped(moduleExports.Channel.prototype.publish)) {
this._wrap(
moduleExports.Channel.prototype,
"publish",
'publish',
this.getPublishPatch.bind(this, moduleVersion)
);
}
if (!isWrapped(moduleExports.Channel.prototype.consume)) {
this._wrap(
moduleExports.Channel.prototype,
"consume",
'consume',
this.getConsumePatch.bind(this, moduleVersion)
);
}
if (!isWrapped(moduleExports.Channel.prototype.ack)) {
this._wrap(
moduleExports.Channel.prototype,
"ack",
'ack',
this.getAckPatch.bind(this, false, EndOperation.Ack)
);
}
if (!isWrapped(moduleExports.Channel.prototype.nack)) {
this._wrap(
moduleExports.Channel.prototype,
"nack",
'nack',
this.getAckPatch.bind(this, true, EndOperation.Nack)
);
}
if (!isWrapped(moduleExports.Channel.prototype.reject)) {
this._wrap(
moduleExports.Channel.prototype,
"reject",
'reject',
this.getAckPatch.bind(this, true, EndOperation.Reject)
);
}
if (!isWrapped(moduleExports.Channel.prototype.ackAll)) {
this._wrap(
moduleExports.Channel.prototype,
"ackAll",
'ackAll',
this.getAckAllPatch.bind(this, false, EndOperation.AckAll)
);
}
if (!isWrapped(moduleExports.Channel.prototype.nackAll)) {
this._wrap(
moduleExports.Channel.prototype,
"nackAll",
'nackAll',
this.getAckAllPatch.bind(this, true, EndOperation.NackAll)
);
}
if (!isWrapped(moduleExports.Channel.prototype.emit)) {
this._wrap(
moduleExports.Channel.prototype,
"emit",
'emit',
this.getChannelEmitPatch.bind(this)
);
}
if (!isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {
this._wrap(
moduleExports.ConfirmChannel.prototype,
"publish",
'publish',
this.getConfirmedPublishPatch.bind(this, moduleVersion)
);
}
Expand All @@ -203,31 +203,31 @@ export class AmqplibInstrumentation extends InstrumentationBase {

private unpatchChannelModel(moduleExports: any) {
if (isWrapped(moduleExports.Channel.prototype.publish)) {
this._unwrap(moduleExports.Channel.prototype, "publish");
this._unwrap(moduleExports.Channel.prototype, 'publish');
}
if (isWrapped(moduleExports.Channel.prototype.consume)) {
this._unwrap(moduleExports.Channel.prototype, "consume");
this._unwrap(moduleExports.Channel.prototype, 'consume');
}
if (isWrapped(moduleExports.Channel.prototype.ack)) {
this._unwrap(moduleExports.Channel.prototype, "ack");
this._unwrap(moduleExports.Channel.prototype, 'ack');
}
if (isWrapped(moduleExports.Channel.prototype.nack)) {
this._unwrap(moduleExports.Channel.prototype, "nack");
this._unwrap(moduleExports.Channel.prototype, 'nack');
}
if (isWrapped(moduleExports.Channel.prototype.reject)) {
this._unwrap(moduleExports.Channel.prototype, "reject");
this._unwrap(moduleExports.Channel.prototype, 'reject');
}
if (isWrapped(moduleExports.Channel.prototype.ackAll)) {
this._unwrap(moduleExports.Channel.prototype, "ackAll");
this._unwrap(moduleExports.Channel.prototype, 'ackAll');
}
if (isWrapped(moduleExports.Channel.prototype.nackAll)) {
this._unwrap(moduleExports.Channel.prototype, "nackAll");
this._unwrap(moduleExports.Channel.prototype, 'nackAll');
}
if (isWrapped(moduleExports.Channel.prototype.emit)) {
this._unwrap(moduleExports.Channel.prototype, "emit");
this._unwrap(moduleExports.Channel.prototype, 'emit');
}
if (isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {
this._unwrap(moduleExports.ConfirmChannel.prototype, "publish");
this._unwrap(moduleExports.ConfirmChannel.prototype, 'publish');
}
return moduleExports;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ export class AmqplibInstrumentation extends InstrumentationBase {
this: InstrumentationConsumeChannel,
eventName: string
) {
if (eventName === "close") {
if (eventName === 'close') {
self.endAllSpansOnChannel(
this,
true,
Expand All @@ -289,7 +289,7 @@ export class AmqplibInstrumentation extends InstrumentationBase {
clearInterval(activeTimer);
}
this[CHANNEL_CONSUME_TIMEOUT_TIMER] = undefined;
} else if (eventName === "error") {
} else if (eventName === 'error') {
self.endAllSpansOnChannel(
this,
true,
Expand Down Expand Up @@ -436,7 +436,7 @@ export class AmqplibInstrumentation extends InstrumentationBase {
() => self._config.consumeHook!(span, { moduleVersion, msg }),
(e) => {
if (e) {
diag.error("amqplib instrumentation: consumerHook error", e);
diag.error('amqplib instrumentation: consumerHook error', e);
}
},
true
Expand Down Expand Up @@ -501,9 +501,9 @@ export class AmqplibInstrumentation extends InstrumentationBase {
options: modifiedOptions,
isConfirmChannel: true,
}),
(e) => {
e => {
if (e) {
diag.error("amqplib instrumentation: publishHook error", e);
diag.error('amqplib instrumentation: publishHook error', e);
}
},
true
Expand All @@ -530,10 +530,10 @@ export class AmqplibInstrumentation extends InstrumentationBase {
isConfirmChannel: true,
confirmError: err,
}),
(e) => {
e => {
if (e) {
diag.error(
"amqplib instrumentation: publishConfirmHook error",
'amqplib instrumentation: publishConfirmHook error',
e
);
}
Expand Down Expand Up @@ -601,9 +601,9 @@ export class AmqplibInstrumentation extends InstrumentationBase {
options: modifiedOptions,
isConfirmChannel: false,
}),
(e) => {
e => {
if (e) {
diag.error("amqplib instrumentation: publishHook error", e);
diag.error('amqplib instrumentation: publishHook error', e);
}
},
true
Expand Down Expand Up @@ -673,10 +673,10 @@ export class AmqplibInstrumentation extends InstrumentationBase {
operation !== EndOperation.ChannelError
? `${operation} called on message${
requeue === true
? " with requeue"
? ' with requeue'
: requeue === false
? " without requeue"
: ""
? ' without requeue'
: ''
}`
: operation,
});
Expand Down Expand Up @@ -712,7 +712,7 @@ export class AmqplibInstrumentation extends InstrumentationBase {
() => this._config.consumeEndHook!(span, { msg, rejected, endOperation }),
(e) => {
if (e) {
diag.error("amqplib instrumentation: consumerEndHook error", e);
diag.error('amqplib instrumentation: consumerEndHook error', e);
}
},
true
Expand Down

0 comments on commit 3fcf648

Please sign in to comment.