@@ -330,6 +330,8 @@ class Connection(NativeResource):
330330
331331 proxy_options (Optional[awscrt.http.HttpProxyOptions]):
332332 Optional proxy options for all connections.
333+
334+ enable_metrics (bool): If true, append AWS IoT metrics to the username. (Default to true)
333335 """
334336
335337 def __init__ (self ,
@@ -355,7 +357,8 @@ def __init__(self,
355357 proxy_options = None ,
356358 on_connection_success = None ,
357359 on_connection_failure = None ,
358- on_connection_closed = None
360+ on_connection_closed = None ,
361+ enable_metrics = True
359362 ):
360363
361364 assert isinstance (client , Client ) or isinstance (client , Mqtt5Client )
@@ -404,8 +407,12 @@ def __init__(self,
404407 self .ping_timeout_ms = ping_timeout_ms
405408 self .protocol_operation_timeout_ms = protocol_operation_timeout_ms
406409 self .will = will
407- username = username if username else ""
408- self .username = username + _get_awsiot_metrics_str (username if username else "" )
410+
411+ if enable_metrics :
412+ username = username if username else ""
413+ username += _get_awsiot_metrics_str (username )
414+
415+ self .username = username
409416 self .password = password
410417 self .socket_options = socket_options if socket_options else SocketOptions ()
411418 self .proxy_options = proxy_options if proxy_options else websocket_proxy_options
0 commit comments