Skip to content
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

RSDK-6170 - add debug log support #299

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stuqdog
Copy link
Member

@stuqdog stuqdog commented Oct 1, 2024

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_properties and is_moving, e.g.) do not take extra as 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 add extra to 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:

#include <viam/sdk/common/proto_type.hpp>
#include <viam/sdk/components/motor.hpp>

auto robot = connect();

auto m = robot->resource_by_name<Motor>("<my-motor-name>");
// "my-cool-key" is optional; if not provided, a random key will be created
AttributeMap with_key = debug_map("my-cool-key"); 
// alternatively if you already have a map you could call `add_debug_entry(my_map, "my-cool-key");` 
m->go_for(100, 2, with_key);

example output:
Screenshot 2024-10-01 at 11 00 10

Flybys:

  • remove some include/using invocations
  • Add extra-less, inline Arm::move_to_joint_positions

@stuqdog stuqdog requested a review from lia-viam October 1, 2024 16:48
@stuqdog stuqdog requested a review from a team as a code owner October 1, 2024 16:48
@stuqdog stuqdog requested review from purplenicole730 and removed request for a team October 1, 2024 16:48
@stuqdog
Copy link
Member Author

stuqdog commented Oct 1, 2024

@dgottlieb fyi!

@stuqdog
Copy link
Member Author

stuqdog commented Oct 1, 2024

Just noticed that the commit hash starts with 993355757. which isn't important at all but I kinda like it.

Copy link
Contributor

@lia-viam lia-viam left a 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?

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
Copy link
Contributor

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

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);
Copy link
Contributor

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?


AttributeMap debug_map() {
auto debug_key = random_debug_key();
return debug_map(debug_key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return debug_map(debug_key);
return debug_map(random_debug_key());

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