Skip to content

Commit

Permalink
fix: solve review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Oct 9, 2023
1 parent ad3c224 commit 5d83cf2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/aedes-instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,13 @@ export class AedesInstrumentation extends InstrumentationBase {
const client = handleSubscribeCtx.getValue(CLIENT_CONTEXT_KEY) as
| AedesClient
| undefined
const currentContext = context.active()

function patchedDeliverFunc(
this: unknown, // default to MQEmitter
packet: AedesPublishPacket,
callback: () => void
) {
const parentContext = getContextFromPacket(packet, currentContext)
const parentContext = getContextFromPacket(packet, handleSubscribeCtx)
const startTime = hrTime()
const topic = packet.topic
const attributes = {
Expand Down Expand Up @@ -499,6 +498,10 @@ export class AedesInstrumentation extends InstrumentationBase {
return cb.apply(this)
}

// TODO depending on QoS :
// - span should be ended in this function for QoS 0 and 1
// - span should be ended in packet ack for QoS 2

return func.call(this, packet, patchedCallback)
}
args[1] = patchedDeliverFunc
Expand Down

0 comments on commit 5d83cf2

Please sign in to comment.