Skip to content

Add IoT SDK Metrics V2 with feature encoding and metadata support#994

Open
rakshil14-2 wants to merge 11 commits into
mainfrom
iot_metrics_improvement
Open

Add IoT SDK Metrics V2 with feature encoding and metadata support#994
rakshil14-2 wants to merge 11 commits into
mainfrom
iot_metrics_improvement

Conversation

@rakshil14-2

Copy link
Copy Markdown

Issue #, if available:

Description of changes:

  • Added metadata entries support to IoTDeviceSDKMetrics for passing key-value metrics through JNI to aws-c-mqtt
  • Added IoTMetricEncoder that encodes CRT-level features (protocol, socket, TLS, proxy, jitter, session, queue, topic alias) into compact "ID/Value" format
  • Added metrics creation/merge logic : auto-sets CRTVersion, validates IoTSDKMetricsVersion before merging SDK features
  • Added user-configurable metrics API (withMetrics() / setMetrics()) for IoT SDK layer
  • Renamed metricsEnableddisableMetrics (opt-out pattern, default false)
  • Stored TLS cipher preference and min TLS version on TlsContext for feature reporting
  • Updated JNI layer to parse metadata entries list and pass to C
  • Added unit tests for encoding, merging, and version validation

Breaking changes:

  • withMetricsEnabled(boolean)withDisableMetrics(boolean)
  • getMetricsEnabled()getDisableMetrics()

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

Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTDeviceSDKMetrics.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTMetricEncoder.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTMetricEncoder.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTMetricEncoder.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/io/TlsContext.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTMetricEncoder.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/internal/IoTMetricEncoder.java Outdated
Comment thread src/main/java/software/amazon/awssdk/crt/mqtt/MqttConnectionConfig.java Outdated
Comment thread src/native/iot_device_sdk_metrics.c Outdated
Comment thread src/native/iot_device_sdk_metrics.c Outdated
(jstring)(*env)->GetObjectField(env, entry, iot_metrics_metadata_properties.key_field_id);
jstring value_jstr =
(jstring)(*env)->GetObjectField(env, entry, iot_metrics_metadata_properties.value_field_id);
if (key_jstr != NULL && value_jstr != NULL) {

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.

As mentioned in Python PR, empty key or empty value is valid case. While I'm not sure how GetObjectField handled undefined fields though.

Comment thread src/native/iot_device_sdk_metrics.c Outdated
java_metrics->metrics.metadata_count = java_metrics->metadata_count;
}

(*env)->DeleteLocalRef(env, metadata_list);

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'm not familiar with JNI memory management. Could you confirm that delete the jni object would not release the memory buffer? Could we have full crt logS that shows that metadata fields are set properly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

DeleteLocalRef: It will just release the local reference without affecting the memory buffer

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