Skip to content

Commit

Permalink
Result of --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Feb 17, 2025
1 parent 05906d7 commit eca3d52
Show file tree
Hide file tree
Showing 103 changed files with 533 additions and 536 deletions.
2 changes: 1 addition & 1 deletion packages/datadog-instrumentations/src/aerospike.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function wrapCreateCommand (createCommand) {
if (typeof createCommand !== 'function') return createCommand

return function commandWithTrace () {
const CommandClass = createCommand.apply(this, arguments)
const CommandClass = Reflect.apply(createCommand, this, arguments)

if (!CommandClass) return CommandClass

Expand Down
8 changes: 4 additions & 4 deletions packages/datadog-instrumentations/src/amqp10.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ addHook({ name: 'amqp10', file: 'lib/sender_link.js', versions: ['>=3'] }, Sende
const errorCh = channel('apm:amqp10:send:error')
shimmer.wrap(SenderLink.prototype, 'send', send => function (msg, options) {
if (!startCh.hasSubscribers) {
return send.apply(this, arguments)
return Reflect.apply(send, this, arguments)
}
const asyncResource = new AsyncResource('bound-anonymous-fn')
return asyncResource.runInAsyncScope(() => {
startCh.publish({ link: this })
try {
const promise = send.apply(this, arguments)
const promise = Reflect.apply(send, this, arguments)

if (!promise) {
finish(finishCh, errorCh)
Expand All @@ -45,13 +45,13 @@ addHook({ name: 'amqp10', file: 'lib/receiver_link.js', versions: ['>=3'] }, Rec
const errorCh = channel('apm:amqp10:receive:error')
shimmer.wrap(ReceiverLink.prototype, '_messageReceived', messageReceived => function (transferFrame) {
if (!transferFrame || transferFrame.aborted || transferFrame.more) {
return messageReceived.apply(this, arguments)
return Reflect.apply(messageReceived, this, arguments)
}
const asyncResource = new AsyncResource('bound-anonymous-fn')
return asyncResource.runInAsyncScope(() => {
startCh.publish({ link: this })
try {
return messageReceived.apply(this, arguments)
return Reflect.apply(messageReceived, this, arguments)
} catch (err) {
errorCh.publish(err)
throw err
Expand Down
14 changes: 7 additions & 7 deletions packages/datadog-instrumentations/src/amqplib.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addHook({ name: 'amqplib', file: 'lib/defs.js', versions: [MIN_VERSION] }, defs

addHook({ name: 'amqplib', file: 'lib/channel_model.js', versions: [MIN_VERSION] }, x => {
shimmer.wrap(x.Channel.prototype, 'get', getMessage => function (queue, options) {
return getMessage.apply(this, arguments).then(message => {
return Reflect.apply(getMessage, this, arguments).then(message => {
if (message === null) {
return message
}
Expand All @@ -39,7 +39,7 @@ addHook({ name: 'amqplib', file: 'lib/channel_model.js', versions: [MIN_VERSION]
})
shimmer.wrap(x.Channel.prototype, 'consume', consume => function (queue, callback, options) {
if (!startCh.hasSubscribers) {
return consume.apply(this, arguments)
return Reflect.apply(consume, this, arguments)
}
arguments[1] = (message, ...args) => {
if (message === null) {
Expand All @@ -50,15 +50,15 @@ addHook({ name: 'amqplib', file: 'lib/channel_model.js', versions: [MIN_VERSION]
finishCh.publish()
return result
}
return consume.apply(this, arguments)
return Reflect.apply(consume, this, arguments)
})
return x
})

addHook({ name: 'amqplib', file: 'lib/callback_model.js', versions: [MIN_VERSION] }, channel => {
shimmer.wrap(channel.Channel.prototype, 'get', getMessage => function (queue, options, callback) {
if (!startCh.hasSubscribers) {
return getMessage.apply(this, arguments)
return Reflect.apply(getMessage, this, arguments)
}
arguments[2] = (error, message, ...args) => {
if (error !== null || message === null) {
Expand All @@ -69,11 +69,11 @@ addHook({ name: 'amqplib', file: 'lib/callback_model.js', versions: [MIN_VERSION
finishCh.publish()
return result
}
return getMessage.apply(this, arguments)
return Reflect.apply(getMessage, this, arguments)
})
shimmer.wrap(channel.Channel.prototype, 'consume', consume => function (queue, callback) {
if (!startCh.hasSubscribers) {
return consume.apply(this, arguments)
return Reflect.apply(consume, this, arguments)
}
arguments[1] = (message, ...args) => {
if (message === null) {
Expand All @@ -84,7 +84,7 @@ addHook({ name: 'amqplib', file: 'lib/callback_model.js', versions: [MIN_VERSION
finishCh.publish()
return result
}
return consume.apply(this, arguments)
return Reflect.apply(consume, this, arguments)
})
return channel
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ addHook({ name: 'apollo-server-core', file: 'dist/runHttpQuery.js', versions: ['
shimmer.wrap(runHttpQueryModule, 'runHttpQuery', function wrapRunHttpQuery (originalRunHttpQuery) {
return async function runHttpQuery () {
if (!requestChannel.start.hasSubscribers) {
return originalRunHttpQuery.apply(this, arguments)
return Reflect.apply(originalRunHttpQuery, this, arguments)
}

const abortController = new AbortController()
Expand Down
6 changes: 3 additions & 3 deletions packages/datadog-instrumentations/src/apollo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let HeaderMap
function wrapExecuteHTTPGraphQLRequest (originalExecuteHTTPGraphQLRequest) {
return async function executeHTTPGraphQLRequest () {
if (!HeaderMap || !requestChannel.start.hasSubscribers) {
return originalExecuteHTTPGraphQLRequest.apply(this, arguments)
return Reflect.apply(originalExecuteHTTPGraphQLRequest, this, arguments)
}

const abortController = new AbortController()
Expand Down Expand Up @@ -53,11 +53,11 @@ function wrapExecuteHTTPGraphQLRequest (originalExecuteHTTPGraphQLRequest) {
function apolloExpress4Hook (express4) {
shimmer.wrap(express4, 'expressMiddleware', function wrapExpressMiddleware (originalExpressMiddleware) {
return function expressMiddleware (server, options) {
const originalMiddleware = originalExpressMiddleware.apply(this, arguments)
const originalMiddleware = Reflect.apply(originalExpressMiddleware, this, arguments)

return shimmer.wrapFunction(originalMiddleware, originalMiddleware => function (req, res, next) {
if (!graphqlMiddlewareChannel.start.hasSubscribers) {
return originalMiddleware.apply(this, arguments)
return Reflect.apply(originalMiddleware, this, arguments)
}

return graphqlMiddlewareChannel.traceSync(originalMiddleware, { req }, this, ...arguments)
Expand Down
8 changes: 4 additions & 4 deletions packages/datadog-instrumentations/src/avsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ const deserializeChannel = dc.channel('apm:avsc:deserialize-end')
function wrapSerialization (Type) {
shimmer.wrap(Type.prototype, 'toBuffer', original => function () {
if (!serializeChannel.hasSubscribers) {
return original.apply(this, arguments)
return Reflect.apply(original, this, arguments)
}
serializeChannel.publish({ messageClass: this })
return original.apply(this, arguments)
return Reflect.apply(original, this, arguments)
})
}

function wrapDeserialization (Type) {
shimmer.wrap(Type.prototype, 'fromBuffer', original => function () {
if (!deserializeChannel.hasSubscribers) {
return original.apply(this, arguments)
return Reflect.apply(original, this, arguments)
}
const result = original.apply(this, arguments)
const result = Reflect.apply(original, this, arguments)
deserializeChannel.publish({ messageClass: result })
return result
})
Expand Down
16 changes: 8 additions & 8 deletions packages/datadog-instrumentations/src/aws-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const shimmer = require('../../datadog-shimmer')

function wrapRequest (send) {
return function wrappedRequest (cb) {
if (!this.service) return send.apply(this, arguments)
if (!this.service) return Reflect.apply(send, this, arguments)

const serviceIdentifier = this.service.serviceIdentifier
const channelSuffix = getChannelSuffix(serviceIdentifier)
const startCh = channel(`apm:aws:request:start:${channelSuffix}`)
if (!startCh.hasSubscribers) return send.apply(this, arguments)
if (!startCh.hasSubscribers) return Reflect.apply(send, this, arguments)
const innerAr = new AsyncResource('apm:aws:request:inner')
const outerAr = new AsyncResource('apm:aws:request:outer')

Expand All @@ -35,7 +35,7 @@ function wrapRequest (send) {
if (typeof cb === 'function') {
arguments[0] = wrapCb(cb, channelSuffix, this, outerAr)
}
return send.apply(this, arguments)
return Reflect.apply(send, this, arguments)
})
}
}
Expand All @@ -48,7 +48,7 @@ function wrapDeserialize (deserialize, channelSuffix) {
headersCh.publish({ headers: response.headers })
}

return deserialize.apply(this, arguments)
return Reflect.apply(deserialize, this, arguments)
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ function wrapSmithySend (send) {
outerAr.runInAsyncScope(() => {
responseStartChannel.publish(message)

cb.apply(this, arguments)
Reflect.apply(cb, this, arguments)

if (message.needsFinish) {
responseFinishChannel.publish(message.response.error)
Expand Down Expand Up @@ -135,11 +135,11 @@ function wrapCb (cb, serviceName, request, ar) {
channel(`apm:aws:response:start:${serviceName}`).publish(obj)
// TODO(bengl) make this work without needing a needsFinish property added to the object
if (!obj.needsFinish) {
return cb.apply(this, arguments)
return Reflect.apply(cb, this, arguments)
}
const finishChannel = channel(`apm:aws:response:finish:${serviceName}`)
try {
let result = cb.apply(this, arguments)
let result = Reflect.apply(cb, this, arguments)
if (result && result.then) {
result = result.then(x => {
finishChannel.publish()
Expand Down Expand Up @@ -205,7 +205,7 @@ addHook({ name: '@aws-sdk/smithy-client', versions: ['>=3'] }, smithy => {
addHook({ name: 'aws-sdk', versions: ['>=2.3.0'] }, AWS => {
shimmer.wrap(AWS.config, 'setPromisesDependency', setPromisesDependency => {
return function wrappedSetPromisesDependency (dep) {
const result = setPromisesDependency.apply(this, arguments)
const result = Reflect.apply(setPromisesDependency, this, arguments)
shimmer.wrap(AWS.Request.prototype, 'promise', wrapRequest)
return result
}
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-instrumentations/src/azure-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function wrapHandler (method) {
const handler = arg
arguments[1] = shimmer.wrapFunction(handler, handler => traceHandler(handler, name, method.name))
}
return method.apply(this, arguments)
return Reflect.apply(method, this, arguments)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-instrumentations/src/bluebird.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const shimmer = require('../../datadog-shimmer')
function createGetNewLibraryCopyWrap (originalLib) {
return function wrapGetNewLibraryCopy (getNewLibraryCopy) {
return function getNewLibraryCopyWithTrace () {
const libraryCopy = getNewLibraryCopy.apply(this, arguments)
const libraryCopy = Reflect.apply(getNewLibraryCopy, this, arguments)
shimmer.wrap(libraryCopy.prototype, '_then', wrapThen)
shimmer.wrap(libraryCopy, 'getNewLibraryCopy', createGetNewLibraryCopyWrap(originalLib))
return libraryCopy
Expand Down
6 changes: 3 additions & 3 deletions packages/datadog-instrumentations/src/body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function publishRequestBodyAndNext (req, res, next) {
if (abortController.signal.aborted) return
}

return next.apply(this, arguments)
return Reflect.apply(next, this, arguments)
})
}

Expand All @@ -28,7 +28,7 @@ addHook({
return shimmer.wrapFunction(read, read => function (req, res, next) {
const nextResource = new AsyncResource('bound-anonymous-fn')
arguments[2] = nextResource.bind(publishRequestBodyAndNext(req, res, next))
return read.apply(this, arguments)
return Reflect.apply(read, this, arguments)
})
})

Expand All @@ -39,6 +39,6 @@ addHook({
}, read => {
return shimmer.wrapFunction(read, read => function (req, res, next) {
arguments[2] = publishRequestBodyAndNext(req, res, next)
return read.apply(this, arguments)
return Reflect.apply(read, this, arguments)
})
})
2 changes: 1 addition & 1 deletion packages/datadog-instrumentations/src/bunyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ addHook({ name: 'bunyan', versions: ['>=1'] }, Logger => {
logCh.publish(payload)
arguments[0] = payload.message
}
return emit.apply(this, arguments)
return Reflect.apply(emit, this, arguments)
}
})
return Logger
Expand Down
Loading

0 comments on commit eca3d52

Please sign in to comment.