-
Notifications
You must be signed in to change notification settings - Fork 26
RSDK-6170 - add debug log support #299
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
Conversation
|
@dgottlieb fyi! |
|
Just noticed that the commit hash starts with |
lia-viam
left a comment
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.
Mostly minor changes, maybe we should also add a change to one of the unit tests using a peek_debug_key parameter or similar?
src/viam/sdk/common/utils.hpp
Outdated
| AttributeMap debug_map(std::string debug_key); | ||
|
|
||
| /// @brief Adds @param debug_key for server-side debug logging to @param map | ||
| /// @throws Exception if the debug_key contains invalid (e.g., uppercase )gRPC characters |
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.
slight typo with the close paren
src/viam/sdk/common/utils.hpp
Outdated
| AttributeMap add_debug_entry(AttributeMap map, std::string debug_key); | ||
|
|
||
| /// @brief Adds a random key to @param map for server-side debug logging | ||
| AttributeMap add_debug_entry(AttributeMap&& map); |
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 and the one above should probably pass the parameter in the same 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.
Hmm maybe you can help me out here! I have an add_debug_entry that passes the param the same way above, but with just those two I get compilation errors (candidate function not viable: expects an rvalue for 1st argument). Having the "pass by value" version fixed that, though perhaps it shouldn't be exposed to users?
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.
actually nevermind! I think after I rebase with your ProtoStruct changes this issue goes away :)
edit: actually maybe not haha, we'll see!
edit edit: okay std::move okay I think we're good.
src/viam/sdk/common/utils.cpp
Outdated
|
|
||
| AttributeMap debug_map() { | ||
| auto debug_key = random_debug_key(); | ||
| return debug_map(debug_key); |
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.
| return debug_map(debug_key); | |
| return debug_map(random_debug_key()); |
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.
looks like this suggestion doesn't remove the debug_key variable creation so I'm modifying locally and pushing, but will make this change!
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.
oops yes haha limitation of github inline code suggestions
|
ok sorry for the bikeshedding but the parameter passing thing got me thinking, maybe we should rename Meow m;
other_function(add_something(std::move(m)); // m is now in moved-from stateI think that something like void add_debug_entry(ProtoStruct&);
ProtoStruct with_debug_entry(ProtoStruct&&);
void f()
{
ProtoStruct s1{{"cat", "meow"}};
add_debug_entry(s1);
component.doCommand(s1);
component.doCommand(withDebugEntry(ProtoStruct{{"dog", "woof"}}));
}And then I think |
|
@lia-viam ooh yeah I like that change, thanks! just added :) |
src/viam/sdk/tests/test_motion.cpp
Outdated
| std::vector<WorldState::transform> transforms; | ||
| ProtoStruct extra = fake_map(); | ||
| std::string debug_key = "debug-key"; | ||
| extra = add_debug_entry(std::move(extra), debug_key); |
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.
I think now that add_debug_entry is void this will need a change, maybe you can change the get_pose call below to be
pose_in_frame pose = client.get_pose(fake_component_name(), destination_frame, {}, with_debug_entry(fake_map(), debug_key));and the above line deleted, then technically we'll be testing both the add and move version.
Other than that LGTM though, and feel free to merge without re-requesting review once the build passes
Adds support for server-side debug logging.
Note to reviewers: this PR gets us 90+% of the way to where we want to be. The problem is that a few methods (
get_propertiesandis_moving, e.g.) do not takeextraas a param. I spent some time brainstorming but I don't see a way to support adding debug logs for these without adding new params to the methods (which would be breaking). Even if we decided to break things, we'd either have to addextrato these (which would be misleading to users) or add a special field to these (which would have unclear/ambiguous utility to many implementers and would create inconsistency in our implementation that could be confusing for users). As such, I've opted to go with the "good enough" approach; we can cross this bridge if/when if a user desperately needs debug log support for these particular methods sometime in the future.example code:
example output:

Flybys:
include/usinginvocationsArm::move_to_joint_positions