-
Notifications
You must be signed in to change notification settings - Fork 43
Add IoT Metrics Support #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
1d8a7aa
binding metrics. Custom Auth related test should fail
xiazhvera 77814a6
update custome auth tests and adapter
xiazhvera 50a04aa
Merge branch 'main' of https://github.com/awslabs/aws-crt-java into i…
xiazhvera a3376ed
update test for adapter
xiazhvera 129e2d1
cleanup
xiazhvera c52ba49
lint
xiazhvera 1e935fe
Merge branch 'main' of https://github.com/awslabs/aws-crt-java into i…
xiazhvera 9b506f3
update jni-config
xiazhvera 6fb3333
Merge branch 'main' into iot_metrics
xiazhvera af9d6ab
Merge branch 'main' into iot_metrics
xiazhvera 3066559
Merge branch 'main' into iot_metrics
xiazhvera a61572c
and retry
xiazhvera 203d0e1
Merge branch 'main' into iot_metrics
xiazhvera 63c143d
set metrics should not fail the connection
xiazhvera 2bbb311
set metrics should not fail the connection
xiazhvera c8f1275
set metrics should not fail the mqtt5 client
xiazhvera a0c5f34
update metrics naming
xiazhvera 67e3770
Merge branch 'main' into iot_metrics
xiazhvera 21e2cb7
update mqtt library
xiazhvera 07a0e42
Merge branch 'iot_metrics' of https://github.com/awslabs/aws-crt-java…
xiazhvera ceaf372
Merge branch 'main' into iot_metrics
xiazhvera 8ec2d38
add metrics enabled tests
xiazhvera 0d276ad
Merge branch 'iot_metrics' of https://github.com/awslabs/aws-crt-java…
xiazhvera 20fa798
fix error
xiazhvera e67a0f4
catch error for connection failure
xiazhvera 9258ac2
Merge branch 'main' into iot_metrics
xiazhvera 63510f3
kick codebuild
xiazhvera aff778f
Merge branch 'iot_metrics' of https://github.com/awslabs/aws-crt-java…
xiazhvera 0960a13
Merge branch 'main' into iot_metrics
xiazhvera 0960bd3
Merge branch 'main' into iot_metrics
xiazhvera 18cf8d0
improve comments
xiazhvera 8011392
Merge branch 'main' into iot_metrics
xiazhvera 3084e05
Merge branch 'main' into iot_metrics
xiazhvera 57e9c1e
update cr comments
xiazhvera d285288
improve comments
xiazhvera 05cd17d
Merge branch 'main' into iot_metrics
xiazhvera b563eea
update cr comments
xiazhvera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/software/amazon/awssdk/crt/internal/IoTDeviceSDKMetrics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
| package software.amazon.awssdk.crt.internal; | ||
|
|
||
| /** | ||
| * @internal | ||
| * IoT Device SDK Metrics Structure. Not for external usage. | ||
| */ | ||
| public class IoTDeviceSDKMetrics { | ||
| private String libraryName; | ||
|
|
||
| public IoTDeviceSDKMetrics() { | ||
| this.libraryName = "IoTDeviceSDK/Java"; | ||
| } | ||
|
|
||
| public String getLibraryName() { | ||
| return libraryName; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
| #include <jni.h> | ||
|
|
||
| #include "iot_device_sdk_metrics.h" | ||
| #include "mqtt5_packets.h" | ||
| #include <aws/mqtt/mqtt.h> | ||
| #include <crt.h> | ||
| #include <java_class_ids.h> | ||
|
|
||
| static char s_iot_device_sdk_metrics_string[] = "IoTDeviceSDKMetrics"; | ||
|
|
||
| void aws_mqtt_iot_metrics_java_jni_destroy( | ||
| JNIEnv *env, | ||
| struct aws_allocator *allocator, | ||
| struct aws_mqtt_iot_metrics_java_jni *java_metrics) { | ||
| (void)env; | ||
|
|
||
| if (!java_metrics) { | ||
| return; | ||
| } | ||
| AWS_LOGF_DEBUG(AWS_LS_MQTT_GENERAL, "id=%p: Destroying IoTDeviceSDKMetrics", (void *)java_metrics); | ||
|
|
||
| if (aws_byte_buf_is_valid(&java_metrics->library_name_buf)) { | ||
| aws_byte_buf_clean_up(&java_metrics->library_name_buf); | ||
| } | ||
|
|
||
| aws_mem_release(allocator, java_metrics); | ||
| } | ||
|
|
||
| struct aws_mqtt_iot_metrics_java_jni *aws_mqtt_iot_metrics_java_jni_create_from_java( | ||
| JNIEnv *env, | ||
| struct aws_allocator *allocator, | ||
| jobject java_iot_device_sdk_metrics) { | ||
|
|
||
| struct aws_mqtt_iot_metrics_java_jni *java_metrics = | ||
| aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt_iot_metrics_java_jni)); | ||
| if (java_metrics == NULL) { | ||
| AWS_LOGF_ERROR( | ||
| AWS_LS_MQTT_GENERAL, "IoTDeviceSDKMetrics create_from_java: Creating new IoTDeviceSDKMetrics failed"); | ||
| return NULL; | ||
| } | ||
|
|
||
| if (aws_get_string_from_jobject( | ||
| env, | ||
| java_iot_device_sdk_metrics, | ||
| iot_device_sdk_metrics_properties.library_name_field_id, | ||
| s_iot_device_sdk_metrics_string, | ||
| "library name", | ||
| &java_metrics->library_name_buf, | ||
| &java_metrics->metrics.library_name, | ||
| false, | ||
| NULL) == AWS_OP_ERR) { | ||
| AWS_LOGF_ERROR(AWS_LS_MQTT_GENERAL, "IoTDeviceSDKMetrics create_from_java: No library name found"); | ||
| goto on_error; | ||
| } | ||
|
|
||
| return java_metrics; | ||
|
|
||
| on_error: | ||
| /* Clean up */ | ||
| aws_mqtt_iot_metrics_java_jni_destroy(env, allocator, java_metrics); | ||
| return NULL; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
| #ifndef AWS_JNI_IOT_DEVICE_SDK_METRICS_H | ||
| #define AWS_JNI_IOT_DEVICE_SDK_METRICS_H | ||
|
|
||
| #include <aws/mqtt/mqtt.h> | ||
| #include <crt.h> | ||
| #include <jni.h> | ||
|
|
||
| struct aws_mqtt_iot_metrics_java_jni { | ||
| struct aws_mqtt_iot_metrics metrics; | ||
| struct aws_byte_buf library_name_buf; | ||
| }; | ||
|
|
||
| void aws_mqtt_iot_metrics_java_jni_destroy( | ||
| JNIEnv *env, | ||
| struct aws_allocator *allocator, | ||
| struct aws_mqtt_iot_metrics_java_jni *java_metrics); | ||
|
|
||
| struct aws_mqtt_iot_metrics_java_jni *aws_mqtt_iot_metrics_java_jni_create_from_java( | ||
| JNIEnv *env, | ||
| struct aws_allocator *allocator, | ||
| jobject java_iot_device_sdk_metrics); | ||
|
|
||
| #endif /* AWS_JNI_IOT_DEVICE_SDK_METRICS_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: This is an internal class, should we make this private in some way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class must be
publicbecause it's used across different packages within the library:software.amazon.awssdk.crt.mqtt.MqttClientConnectionsoftware.amazon.awssdk.crt.mqtt5.Mqtt5ClientOptionsJava's package-private visibility only works within the same package, so it has to be public as it is used cross packages.
We added it to
InternalPackage to indicate it is not a public API