Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add better logging for mqtt #444

Merged
merged 6 commits into from
Jul 31, 2023

Conversation

kaushik-rishi
Copy link
Contributor

Description

  • Better MQTT logging, for subscription on topics
  • More logging suggestions welcome
    image
    image

Related issue(s)
Resolves #406

@kaushik-rishi
Copy link
Contributor Author

@KhudaDad414 I have a couple of doubts 🙂

  1. I didn't understand what you mean't by adding error handling logic here https://github.com/asyncapi/glee/blob/master/src/adapters/mqtt/index.ts#L117
  2. I did test a failure scenario using some hacky ways, but how can i actually test a failing topic subscription event ?

@kaushik-rishi kaushik-rishi marked this pull request as ready for review May 29, 2023 05:20
@KhudaDad414
Copy link
Member

I didn't understand what you mean't by adding error handling logic here https://github.com/asyncapi/glee/blob/master/src/adapters/mqtt/index.ts#L117

I don't see any error handing logic there. 🤔

I did test a failure scenario using some hacky ways, but how can i actually test a failing topic subscription event ?

have you tried subscribing to a non-existent topic?

@kaushik-rishi
Copy link
Contributor Author

kaushik-rishi commented May 30, 2023

@KhudaDad414

I don't see any error handing logic there. 🤔

This was regarding the implementation section of this #406

You've mentioned to add error handling there, so i asked what it meant 🙂

have you tried subscribing to a non-existent topic?

WDYM by a non existent topic 🤔 ? The topics are automatically being fetched from the asyncapi.yaml file right ? 🙂

@KhudaDad414
Copy link
Member

sorry, I meant here

this.client.subscribe(channel, {

I should have used a permalink instead. 😆

WDYM by a non existent topic 🤔 ? The topics are automatically being fetched from the asyncapi.yaml file right ? 🙂

Sorry, I was thinking topics should be declared before subscribing like some other brokers. 😆
One way that I can think of is trying to subscribe with an invalid QoS in binding.

@kaushik-rishi
Copy link
Contributor Author

kaushik-rishi commented Jun 1, 2023

@KhudaDad414

Sorry, I was thinking topics should be declared before subscribing like some other brokers. laughing One way that I can think of is trying to subscribe with an invalid QoS in binding.

I've tested things and they're working as we expected.
image

A couple of things i've discovered while solving this issue, which could help others

  1. What's QoS ? (sort of agreement for message delivery between client and broker)
    • At most once (0)
    • At least once (1)
    • Exactly once (2).
  2. Invalid binding of qos, was overriden in the library to qos 0, so can't test the error handling using qos
  3. To test the error logging, i went through the mqtt package code https://github.com/mqttjs/MQTT.js/blob/main/lib/validations.js
    • this helped me to determine what topic names are invalid

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

Let's merge this. :)

src/adapters/mqtt/index.ts Outdated Show resolved Hide resolved
src/adapters/mqtt/index.ts Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@KhudaDad414
Copy link
Member

/rtm

@coveralls
Copy link

coveralls commented Jun 5, 2023

Pull Request Test Coverage Report for Build 5140316778

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 60.53%

Totals Coverage Status
Change from base Build 5070706381: 0.0%
Covered Lines: 324
Relevant Lines: 454

💛 - Coveralls

@kaushik-rishi
Copy link
Contributor Author

@KhudaDad414 Why is this PR not being merged yet, is there any code review that i'm missing out on as this shows "Changes Requested" 🤔
I'm kind of confused.

KhudaDad414
KhudaDad414 previously approved these changes Jun 8, 2023
@KhudaDad414
Copy link
Member

Merging it right now. thanks for the contribution. @kaushik-rishi

@KhudaDad414
Copy link
Member

/rtm

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@KhudaDad414
Copy link
Member

/rtm

@KhudaDad414
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 18cded6 into asyncapi:master Jul 31, 2023
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better logging for MQTT adapter
4 participants