1212
1313import software .amazon .awssdk .crt .mqtt5 .packets .ConnectPacket ;
1414import software .amazon .awssdk .crt .mqtt .MqttConnectionConfig ;
15+ import software .amazon .awssdk .crt .internal .IoTDeviceSDKMetrics ;
1516
1617import java .util .Map ;
1718import java .util .function .Function ;
@@ -45,6 +46,12 @@ public class Mqtt5ClientOptions {
4546 private Consumer <Mqtt5WebsocketHandshakeTransformArgs > websocketHandshakeTransform ;
4647 private PublishEvents publishEvents ;
4748 private TopicAliasingOptions topicAliasingOptions ;
49+ // Indicates whether AWS IoT Metrics are enabled for this client, default to true.
50+ // We don't expose iotDeviceSDKMetrics in the builder, and only allow setting
51+ // metricsEnabled for now.
52+ private boolean metricsEnabled = true ;
53+ private IoTDeviceSDKMetrics iotDeviceSDKMetrics ;
54+
4855
4956 /**
5057 * Returns the host name of the MQTT server to connect to.
@@ -263,6 +270,24 @@ public TopicAliasingOptions getTopicAliasingOptions() {
263270 return this .topicAliasingOptions ;
264271 }
265272
273+ /**
274+ * Returns whether AWS IoT Device SDK metrics collection is enabled
275+ *
276+ * @return true if metrics are enabled, false otherwise
277+ */
278+ public boolean getMetricsEnabled () {
279+ return this .metricsEnabled ;
280+ }
281+
282+ /**
283+ * Enables or disables IoT Device SDK metrics collection. The metrics includes SDK name, version, and platform.
284+ *
285+ * @param enabled true to enable metrics, false to disable
286+ */
287+ public void setMetricsEnabled (boolean enabled ) {
288+ this .metricsEnabled = enabled ;
289+ }
290+
266291 /**
267292 * Creates a Mqtt5ClientOptionsBuilder instance
268293 * @param builder The builder to get the Mqtt5ClientOptions values from
@@ -289,6 +314,8 @@ public Mqtt5ClientOptions(Mqtt5ClientOptionsBuilder builder) {
289314 this .websocketHandshakeTransform = builder .websocketHandshakeTransform ;
290315 this .publishEvents = builder .publishEvents ;
291316 this .topicAliasingOptions = builder .topicAliasingOptions ;
317+ this .metricsEnabled = builder .metricsEnabled ;
318+ this .iotDeviceSDKMetrics = new IoTDeviceSDKMetrics ();
292319 }
293320
294321 /*******************************************************************************
@@ -583,6 +610,7 @@ static final public class Mqtt5ClientOptionsBuilder {
583610 private Consumer <Mqtt5WebsocketHandshakeTransformArgs > websocketHandshakeTransform ;
584611 private PublishEvents publishEvents ;
585612 private TopicAliasingOptions topicAliasingOptions ;
613+ private boolean metricsEnabled = true ;
586614
587615 /**
588616 * Sets the host name of the MQTT server to connect to.
@@ -850,6 +878,17 @@ public Mqtt5ClientOptionsBuilder withTopicAliasingOptions(TopicAliasingOptions o
850878 return this ;
851879 }
852880
881+ /**
882+ * Enables or disables IoT Device SDK metrics collection. The metrics includes SDK name, version, and platform.
883+ *
884+ * @param enabled true to enable metrics, false to disable.
885+ * @return The Mqtt5ClientOptionsBuilder after setting the metrics option
886+ */
887+ public Mqtt5ClientOptionsBuilder withMetricsEnabled (boolean enabled ) {
888+ this .metricsEnabled = enabled ;
889+ return this ;
890+ }
891+
853892 /**
854893 * Creates a new Mqtt5ClientOptionsBuilder instance
855894 *
0 commit comments