Skip to content

Conversation

@xiazhvera
Copy link
Contributor

@xiazhvera xiazhvera commented Dec 19, 2025

Issue #, if available:

Description of changes:

  • Bind IoTDeviceSDKMetrics and metrics related features , CRT is now appending AWS metrics by default.
  • Add enableMetrics option to allow user disable metrics.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

* Enable AWS IoT metrics, if not set, default to enabled.
*
* @param enabled enable AWS IoT metrics to collect SDK usage data
* @return The ConnectPacket Object after setting the user property
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be @return this option object or something similar

const Crt::Io::SocketOptions &socketOptions,
Crt::Io::TlsContext &&tlsContext);
Crt::Io::TlsContext &&tlsContext,
bool enableMetrics);
Copy link
Contributor

Choose a reason for hiding this comment

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

Default value for a new argument should be specified here rather than in cpp. The same applies to other methods.

m_connackTimeoutMs(0), m_ackTimeoutSec(0), m_allocator(allocator)
m_connackTimeoutMs(0), m_ackTimeoutSec(0), m_enableMetrics(true), m_allocator(allocator)
{
m_sdkMetrics = Mqtt::IoTDeviceSDKMetrics();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: m_sdkMetrics is already default constructed at this point, so this line can be safely removed.


if (m_enableMetrics)
{
struct aws_mqtt_iot_sdk_metrics metrics;
Copy link
Contributor

Choose a reason for hiding this comment

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

metrics should be zeroed. Otherwise we can get uninitialized fields here on adding meta data in aws-c-mqtt.

Comment on lines +673 to 676
/** Enable AWS IoT Metrics Collection. This is always set to true for now. */
bool m_enableMetricsCollection;

Crt::String m_sdkName = "CPPv2";
Crt::String m_sdkVersion = AWS_CRT_CPP_VERSION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we remove this? I think struct IoTDeviceSDKMetrics handles the metrics now.

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