KL-300: Upgrade aedes to v0.51.3 with OTel instrumentation compatibility#1
Open
rajathongal-intangles wants to merge 31 commits intomainfrom
Open
Conversation
Co-authored-by: steven.frew <steven.frew@corporatemodelling.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
BREAKING CHANGE: Min node version >= 16
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [mqtt-packet](https://github.com/mqttjs/mqtt-packet) from 8.2.1 to 9.0.0. - [Release notes](https://github.com/mqttjs/mqtt-packet/releases) - [Commits](mqttjs/mqtt-packet@v8.2.1...v9.0.0) --- updated-dependencies: - dependency-name: mqtt-packet dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Daniel Lando <daniel.sorridi@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Daniel Lando <daniel.sorridi@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Uladzimir Danko <uladzimirdanko@uladzimirsmbp14.home>
Upgrade mqtt-packet ^8, mqemitter ^5, aedes-persistence ^9, aedes-packet ^3, uuid ^9, hyperid ^3.1. Remove bulk-write-stream. Node engine bumped to >=16. Enables aedes-otel-instrumentation compatibility (requires mqtt-packet >=8).
Merge upstream aedes v0.51.3 (last CJS version) which includes: - Memory leak fix in connected clients counter - Will deletion on disconnect fix - keepaliveLimit option - closeSameClients fix Add OTel instrumentation compatibility changes required by aedes-otel-instrumentation: - Convert all handler/write exports to named exports - Move handler functions (preConnect, authenticate, authorizePublish, authorizeSubscribe, handle) from instance closures to prototype methods - Add wrapDeliveryFunc hook for tracing message delivery spans - Update all require() sites to use destructuring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merges upstream aedes v0.51.3 (last CJS release before ESM migration in v1.0.0) and applies structural changes required by
aedes-otel-instrumentationfor OpenTelemetry auto-span creation.Upstream merge (v0.50.0 → v0.51.3)
Bug fixes and improvements from upstream:
opts.keepaliveLimitoption, fixcloseSameClientsfor already-closed clientsconsole.errorDependency updates
OTel instrumentation compatibility changes
aedes-otel-instrumentation(v0.2.0) uses@opentelemetry/instrumentation'sInstrumentationNodeModuleFileto monkey-patch aedes handler functions. The published npm package includes apostinstall: "patch-package"script but does NOT ship the patch files (patches/is not in thefilesarray). This means the patches are never applied, and the instrumentation silently fails to create spans.We apply the equivalent changes directly in the fork so the instrumentation works out of the box.
1. Named exports (all handler + write files)
Changed from default exports to named exports so
shimmer.wrap(moduleExports, 'handleConnect', ...)can locate the function:Files changed:
connect.js,publish.js,subscribe.js,ping.js,puback.js,pubrec.js,pubrel.js,unsubscribe.js,handlers/index.js,write.jsAll
require()call sites updated to use destructuring (const { handleConnect } = require(...)).2. Prototype methods for handler functions
Moved
handle,preConnect,authenticate,authorizePublish,authorizeSubscribefrom instance closures/properties toAedes.prototypemethods soaedes-otel-instrumentationcan monkey-patch them:3.
wrapDeliveryFunchookNew
wrapDeliveryFuncoption and prototype method — called insubscribe.js'saddSubs()before registering the delivery function. Allowsaedes-otel-instrumentationto wrap each subscription's delivery callback to create{topic} receivespans.Breaking changes for consumers
aedes.handlemust be bound when used as a callbackSince
handlemoved from a closure (capturingthat) to a prototype method (usingthis), passing it as a callback requires.bind(aedes):Direct property assignment still works
Overriding handlers at the instance level (e.g.
aedes.authenticate = customFn) still works — instance properties shadow prototype methods.What this enables
With these changes,
aedes-otel-instrumentationcan now auto-create:mqtt.connectspans (fromhandleConnectpatch){topic} publishspans (fromhandlePublishpatch){topic} receivespans (fromwrapDeliveryFunc+handleSubscribepatch)Aedes.prototype.handlepatch)mqtt.server.durationandmqtt.client.durationmetricsIntangles customizations preserved
emitPacketinaedes.js— IMEI regex filter +SUPPRESS_MQTT_EVENTSflag — unchangedaedes.d.tsCommonJS export declaration — unchangedWhy not v1.0.0?
Upstream v1.0.0+ migrated to ESM (
"type": "module"), which is incompatible with the Backend's CommonJSrequire('aedes'). v0.51.3 is the last CJS release.Related PRs