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: emit mqtt metrics #106

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: emit mqtt metrics #106

wants to merge 2 commits into from

Conversation

vaibhavmurkute
Copy link
Contributor

@vaibhavmurkute vaibhavmurkute commented Jun 30, 2022

Description of changes:

1. Connect.Success : Number of successful client connections
2. Connect.AuthError: The number of connection requests that could not be authorized by the broker
3. Subscribe.Success: Number of successful client subscriptions
4. Subscribe.AuthError: The number of subscription requests that could not be authorized by the broker
5. PublishOut.Success: The number of messages successfully published by the broker
6. PublishIn.AuthError: The number of publish requests that could not be authorized by the broker
7. Disconnect: Number of successful client disconnects
8. Unsubscribe: Number of successful client unsubscribe
9. UnknownAuthError: Number of authorization failures for unknown MQTT operations.

How was this change tested: mvn clean package with unit tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

break;
}
metricsEmitter.emitMetric(Metric.builder()
.namespace(MqttMetrics.MOQUETTE_MQTT_NAMESPACE)
Copy link
Member

Choose a reason for hiding this comment

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

let's talk to cloud team about the namespaces. We may want to share a namespace for any MQTT broker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IoT Core Message broker metrics are under "MQTT" Protocol dimension in "AWS/IoT" namespace. Does it make sense to keep generic "LocalMQTT" namespace housing metrics for our local-mqtt broker?

authErrorMetric = MqttMetrics.UNKNOWN_AUTH_ERROR;
break;
}
metricsEmitter.emitMetric(Metric.builder()
Copy link
Member

Choose a reason for hiding this comment

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

we probably do not want to immediately emit a metric, this can be expensive. We may want to instead batch up a number of them and then emit the sum ourselves on a timer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to schedule batched metric emit

@github-actions
Copy link

github-actions bot commented Jun 30, 2022

Unit Tests Coverage Report

File Coverage Lines Branches
All files 71% 77% 64%
com.aws.greengrass.mqtt.moquette.metrics.MqttMetricsCaptor 17% 17% 0%
com.aws.greengrass.mqtt.moquette.metrics.MqttMetricsEmitter 0% 0% 0%
com.aws.greengrass.mqtt.moquette.metrics.MetricsStore$MqttMetric 100% 100% 0%
com.aws.greengrass.mqtt.moquette.metrics.MetricsStore 100% 100% 0%
com.aws.greengrass.mqtt.moquette.metrics.MetricsStore$MetricsStoreHelper 100% 100% 0%
com.aws.greengrass.mqtt.moquette.GreengrassMoquetteSslContextCreator 51% 60% 41%
com.aws.greengrass.mqtt.moquette.ClientDeviceAuthorizer 91% 94% 88%
com.aws.greengrass.mqtt.moquette.ClientDeviceTrustManager 95% 90% 100%
com.aws.greengrass.mqtt.moquette.BrokerKeyStore 70% 70% 0%
com.aws.greengrass.mqtt.moquette.MQTTService 77% 83% 71%
com.aws.greengrass.mqtt.moquette.ClientDeviceAuthorizer$ConnectionTerminationListener 67% 85% 50%
com.aws.greengrass.mqtt.moquette.ClientDeviceAuthorizer$UserSessionPair 100% 100% 0%

Minimum allowed coverage is 50%

Generated by 🐒 cobertura-action against 2df709a

import javax.inject.Inject;

public class MqttMetricsEmitter {
private static final long DEFAULT_METRIC_EMIT_FREQUENCY_SECONDS = 30;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we make this configurable?

@vaibhavmurkute vaibhavmurkute marked this pull request as ready for review July 1, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants