-
Notifications
You must be signed in to change notification settings - Fork 50
Add IoT Metrics Support #710
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
Open
xiazhvera
wants to merge
19
commits into
main
Choose a base branch
from
iot_metrics_2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−16
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bf5456e
bind sdk metrics
xiazhvera d3d6352
set aws-c-mqtt to test branch
xiazhvera 21fe38d
bind sdk metrics
xiazhvera 13fe021
update aws-c-common
xiazhvera da7ed31
add SdkMetrics in mqtt5 lib
xiazhvera c167b43
move metrics to client option
xiazhvera 2368721
clean up & lint
xiazhvera c456258
Merge branch 'main' into iot_metrics_2
xiazhvera 03e5d98
update test to use client option
xiazhvera 9a9c89d
Merge branch 'iot_metrics_2' of https://github.com/awslabs/aws-crt-py…
xiazhvera 5f3868c
add metrics for adapter
xiazhvera ec40b81
fix param order
xiazhvera fb81ecc
remove custom metrics test
xiazhvera 0435c7f
update test test_metrics_disabled
xiazhvera 3a7b509
Merge branch 'main' into iot_metrics_2
xiazhvera a21e542
Merge branch 'main' into iot_metrics_2
xiazhvera c51a273
kick ci
xiazhvera 2f31d9d
Merge branch 'iot_metrics_2' of https://github.com/awslabs/aws-crt-py…
xiazhvera a6a3c30
fix set metrics error handling
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
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
Submodule aws-c-mqtt
updated
25 files
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 |
|---|---|---|
|
|
@@ -437,6 +437,39 @@ static void s_on_connect( | |
| PyGILState_Release(state); | ||
| } | ||
|
|
||
| /* If unsuccessful, false is returned and a Python error has been set */ | ||
| bool s_set_metrics(struct aws_mqtt_client_connection *connection, PyObject *metrics) { | ||
| assert(metrics && (metrics != Py_None)); | ||
|
|
||
| if (connection == NULL) { | ||
| return false; | ||
| } | ||
|
|
||
| bool success = false; | ||
|
|
||
| PyObject *library_name_py = PyObject_GetAttrString(metrics, "library_name"); | ||
| struct aws_byte_cursor library_name = aws_byte_cursor_from_pyunicode(library_name_py); | ||
| if (!library_name.ptr) { | ||
| PyErr_SetString(PyExc_TypeError, "metrics.library_name must be str type"); | ||
| goto done; | ||
| } | ||
|
|
||
| struct aws_mqtt_iot_sdk_metrics metrics_struct = { | ||
| .library_name = library_name, | ||
| }; | ||
|
|
||
| if (aws_mqtt_client_connection_set_metrics(connection, &metrics_struct)) { | ||
| PyErr_SetAwsLastError(); | ||
| goto done; | ||
| } | ||
|
|
||
| success = true; | ||
|
|
||
| done: | ||
| Py_DECREF(library_name_py); | ||
| return success; | ||
| } | ||
|
|
||
| /* If unsuccessful, false is returned and a Python error has been set */ | ||
| bool s_set_will(struct aws_mqtt_client_connection *connection, PyObject *will) { | ||
| assert(will && (will != Py_None)); | ||
|
|
@@ -668,9 +701,10 @@ PyObject *aws_py_mqtt_client_connection_connect(PyObject *self, PyObject *args) | |
| PyObject *is_clean_session; | ||
| PyObject *on_connect; | ||
| PyObject *proxy_options_py; | ||
| PyObject *metrics_py; | ||
| if (!PyArg_ParseTuple( | ||
| args, | ||
| "Os#s#IOOKKHIIOz#z#OOO", | ||
| "Os#s#IOOKKHIIOz#z#OOOO", | ||
| &impl_capsule, | ||
| &client_id, | ||
| &client_id_len, | ||
|
|
@@ -691,7 +725,8 @@ PyObject *aws_py_mqtt_client_connection_connect(PyObject *self, PyObject *args) | |
| &password_len, | ||
| &is_clean_session, | ||
| &on_connect, | ||
| &proxy_options_py)) { | ||
| &proxy_options_py, | ||
| &metrics_py)) { | ||
| return NULL; | ||
| } | ||
|
|
||
|
|
@@ -773,6 +808,13 @@ PyObject *aws_py_mqtt_client_connection_connect(PyObject *self, PyObject *args) | |
| } | ||
| } | ||
|
|
||
| // If metrics is None, we do not set metrics at all. | ||
| if (metrics_py != Py_None) { | ||
| if (!s_set_metrics(py_connection->native, metrics_py)) { | ||
| goto done; | ||
|
Comment on lines
+813
to
+814
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In crt-cpp, a failure on setting metrics is ignored. Here, it fails connection attempts. I think we should document the correct behavior and implement it everywhere. |
||
| } | ||
| } | ||
|
|
||
| if (on_connect != Py_None) { | ||
| Py_INCREF(on_connect); | ||
| py_connection->on_connect = on_connect; | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.