Skip to content

feat(mqtt): add APM instrumentation for mqtt package#7733

Draft
janhavis wants to merge 2 commits intomasterfrom
apm-ai-toolkit/new_integration/mqtt/20260310-011726
Draft

feat(mqtt): add APM instrumentation for mqtt package#7733
janhavis wants to merge 2 commits intomasterfrom
apm-ai-toolkit/new_integration/mqtt/20260310-011726

Conversation

@janhavis
Copy link

🤖 Generated with APM Instrumentation Toolkit

What does this PR do?

Adds APM instrumentation for the mqtt package (v5.15.0), enabling distributed tracing for MQTT publish/subscribe operations in Node.js applications.

Generated by running:

dd-apm create mqtt --mode=agent

Motivation

MQTT is a widely used messaging protocol for IoT and lightweight pub/sub use cases. This integration gives Datadog customers visibility into MQTT message flows as part of their distributed traces.

Instrumented operations:

  • Publish (producer) — traces outgoing MQTT messages with topic, QoS, and retain metadata
  • Message receipt (consumer) — traces incoming messages on subscribed topics

Additional Notes

  • Module type: CommonJS
  • 4 instrumentation targets identified during analysis
  • Tests generated and validated by the toolkit's test/fix agent loop
  • 2 known lint warnings in the test file (no-unused-vars for tracer/span) — the lint fix agent timed out; these should be cleaned up before merging

Try it out

TOOLKIT_BRANCH=main bash <(gh api 'repos/DataDog/apm-instrumentation-toolkit/contents/bootstrap.sh?ref=main' --jq '.content | @base64d')

🤖 Generated with APM Instrumentation Toolkit

Generated by `dd-apm create mqtt --mode=agent` using the APM Instrumentation Toolkit.

Instruments MQTT publish (producer) and message receipt (consumer) operations
with distributed tracing spans, including topic, QoS, and connection metadata.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@janhavis janhavis added the ai-generated PR created with AI assistance label Mar 10, 2026
@janhavis janhavis marked this pull request as ready for review March 10, 2026 19:43
@janhavis janhavis requested review from a team as code owners March 10, 2026 19:43
@janhavis janhavis requested review from BridgeAR and removed request for a team March 10, 2026 19:43
@pr-commenter
Copy link

pr-commenter bot commented Mar 10, 2026

Benchmarks

Benchmark execution time: 2026-03-10 19:48:35

Comparing candidate commit f9158bd in PR branch apm-ai-toolkit/new_integration/mqtt/20260310-011726 with baseline commit 5107dac in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics.

@github-actions
Copy link
Contributor

Overall package size

Self size: 4.98 MB
Deduped: 5.82 MB
No deduping: 5.82 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-datadog-prod-us1-2
Copy link

datadog-datadog-prod-us1-2 bot commented Mar 10, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 515 Tests failed

tests.integration_frameworks.llm.anthropic.test_anthropic_apm.TestAnthropicApmMessages.test_create[False, anthropic-js@0.71.0] from system_tests_suite (Datadog) (Fix with Cursor)
failed on setup with "Failed: Timeout of 60 seconds exceeded waiting for HTTP server to start. Please check logs."

request = <SubRequest 'test_client' for <Function test_create[False]>>
library_env = {}, test_id = '582457', worker_id = 'master'
test_agent = <utils.docker_fixtures._test_agent.TestAgentAPI object at 0x7fe289f51cd0>

    @pytest.fixture
    def test_client(
        request: pytest.FixtureRequest,
        library_env: dict[str, str],
...
tests.integration_frameworks.llm.anthropic.test_anthropic_apm.TestAnthropicApmMessages.test_create_stream_method[anthropic-js@0.71.0] from system_tests_suite (Datadog) (Fix with Cursor)
failed on setup with "Failed: Timeout of 60 seconds exceeded waiting for HTTP server to start. Please check logs."

request = <SubRequest 'test_client' for <Function test_create_stream_method>>
library_env = {}, test_id = '2a8621', worker_id = 'master'
test_agent = <utils.docker_fixtures._test_agent.TestAgentAPI object at 0x7fe289d5f590>

    @pytest.fixture
    def test_client(
        request: pytest.FixtureRequest,
        library_env: dict[str, str],
...
tests.integration_frameworks.llm.anthropic.test_anthropic_apm.TestAnthropicApmMessages.test_create[True, anthropic-js@0.71.0] from system_tests_suite (Datadog) (Fix with Cursor)
failed on setup with "Failed: Timeout of 60 seconds exceeded waiting for HTTP server to start. Please check logs."

request = <SubRequest 'test_client' for <Function test_create[True]>>
library_env = {}, test_id = 'b44ae5', worker_id = 'master'
test_agent = <utils.docker_fixtures._test_agent.TestAgentAPI object at 0x7fe289f53350>

    @pytest.fixture
    def test_client(
        request: pytest.FixtureRequest,
        library_env: dict[str, str],
...
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1b12cf7 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@tlhunter tlhunter added AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos semver-minor labels Mar 11, 2026
{
"version": "2",
"supportedConfigurations": {
"DD_AAS_DOTNET_EXTENSION_VERSION": ["A"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something very bad happened in this file... Maybe from a rebase issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, @wconti27 fixed this bug as part of this issue.

Copy link
Member

@tlhunter tlhunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supported configurations file needs to be fixed. Does it need to be changed at all? I would only think so if this integration is released as experimental.

@janhavis
Copy link
Author

The supported configurations file needs to be fixed. Does it need to be changed at all? I would only think so if this integration is released as experimental.

This integration is purely experimental. It was run to assess how the toolkit is working.

@tlhunter
Copy link
Member

In that case I'll mark the PR as draft for now

@tlhunter tlhunter marked this pull request as draft March 11, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos ai-generated PR created with AI assistance semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants