Skip to content

Metric update#735

Open
rakshil14-2 wants to merge 4 commits into
mainfrom
metric_update
Open

Metric update#735
rakshil14-2 wants to merge 4 commits into
mainfrom
metric_update

Conversation

@rakshil14-2
Copy link
Copy Markdown

@rakshil14-2 rakshil14-2 commented May 18, 2026

Issue

Description of changes:

  • Made AWSIoTMetrics class as public. This class will hold all information regarding metrics.
  • Add metrics feature encoding for each protocol.
  • Added Metric Options so that user can set own metrics
  • enableMetrics -> disableMetrics : change name convention to disable to focus on the "opt-out" pattern.

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

@rakshil14-2 rakshil14-2 marked this pull request as ready for review May 18, 2026 16:50
@rakshil14-2 rakshil14-2 changed the base branch from iot_metrics_improvement to main May 19, 2026 16:33
Update submodule

added function to track features

lint

making public module

fix CI errors

Added TLS feature at CRT layer

lint

making aws_iot_metric public

updating doc

fix docs error

Introduce Opt-out for Metrics

updating doc_string

updating submodules

Test cases

changing public attributes to private

changed to public attributes
Comment thread awscrt/aws_iot_metrics.py Outdated
# Feature ID Constants


class MetricsFeatureId(str, Enum):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should keep the ids private. I didn't see why end user would need to use or know about the metrics value. Similar for the other encoding value classes.

Comment thread awscrt/aws_iot_metrics.py Outdated

# Merge features: if version matches, merge CRT + SDK; otherwise CRT only
if (user_metrics_version is not None and user_metrics_version.isdigit() and int(
user_metrics_version) == IOT_SDK_METRICS_FEATURE_VERSION and user_feature):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems unnecessary to validate user_features, as the default user_feature will be "".

Comment thread awscrt/aws_iot_metrics.py Outdated
return final_metrics


def create_metrics_mqtt5(client_options):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similarly, create_metrics should be a private APIs.

Comment thread awscrt/aws_iot_metrics.py Outdated
if "/" in pair:
fid, val = pair.split("/", 1)
merged[fid] = val
return ",".join(f"{k}/{v}" for k, v in sorted(merged.items()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I realize we also sorted the feature list in Swift, however, thinking about it, it seems unnecessary to sort the feature list.

Comment thread awscrt/io.py Outdated
options (TlsContextOptions): Configuration options.
"""
__slots__ = ()
__slots__ = ('min_tls_ver', 'cipher_pref')
Copy link
Copy Markdown
Contributor

@xiazhvera xiazhvera May 22, 2026

Choose a reason for hiding this comment

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

As the members are for metrics tracking only, they should not be publicly accessible. Or it should at least be read-only.
Swift made the same mistake.

Comment thread awscrt/mqtt.py Outdated
self.proxy_options = proxy_options if proxy_options else websocket_proxy_options
if enable_metrics:
self._metrics = AWSIoTMetrics()
if not disable_metrics:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Here is a double negative (not disable_metrics), consider flipping the condition for readability.

Comment thread awscrt/mqtt5.py Outdated
# Handle metrics configuration
if client_options.enable_metrics:
self._metrics = AWSIoTMetrics()
if not client_options.disable_metrics:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Similar, double negative (not disable_metrics) here.

Comment thread source/mqtt5_client.c
if (PyObject_IsTrue(is_metrics_enabled_py)) {
metrics_tmp.library_name = metrics_library_name;

if (PyObject_IsTrue(is_metrics_enabled_py) && metrics_py != Py_None) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we have a helper function to handle metrics object, and reuse it across mqtt5 and mqtt3?

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