From 3fcf648885c123bd4bc88f863a8a703c8c77fd17 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 9 Jan 2023 15:45:02 +0100 Subject: [PATCH] refactor(instrumentation-amqplib): revert prettier formatting --- .../instrumentation-amqplib/src/amqplib.ts | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/plugins/node/instrumentation-amqplib/src/amqplib.ts b/plugins/node/instrumentation-amqplib/src/amqplib.ts index fe9c8c954b..0473758f3d 100644 --- a/plugins/node/instrumentation-amqplib/src/amqplib.ts +++ b/plugins/node/instrumentation-amqplib/src/amqplib.ts @@ -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, @@ -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) ); @@ -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] @@ -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; } @@ -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) ); } @@ -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; } @@ -277,7 +277,7 @@ export class AmqplibInstrumentation extends InstrumentationBase { this: InstrumentationConsumeChannel, eventName: string ) { - if (eventName === "close") { + if (eventName === 'close') { self.endAllSpansOnChannel( this, true, @@ -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, @@ -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 @@ -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 @@ -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 ); } @@ -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 @@ -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, }); @@ -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