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

feat: instrument dfx for telemetry #4149

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

adamspofford-dfinity
Copy link
Contributor

No description provided.

@adamspofford-dfinity adamspofford-dfinity force-pushed the spofford/telemetry-instrument branch from 81c0901 to 91450a5 Compare March 13, 2025 16:38
Base automatically changed from sdk-769-telemetry to master March 14, 2025 18:05
@adamspofford-dfinity adamspofford-dfinity force-pushed the spofford/telemetry-instrument branch from a4b5b5c to 31df56c Compare March 14, 2025 18:08
@adamspofford-dfinity adamspofford-dfinity marked this pull request as ready for review March 17, 2025 14:50
@adamspofford-dfinity adamspofford-dfinity requested a review from a team as a code owner March 17, 2025 14:50
@@ -117,6 +186,11 @@ impl Telemetry {

pub fn append_current_command_timestamped(exit_code: i32) -> DfxResult<()> {
try_with_telemetry(|telemetry| {
let reject = telemetry.last_reject.as_ref();
let call_site = telemetry.last_operation.as_ref().map(|o| match o {
Operation::Call { method, .. } => method,

Choose a reason for hiding this comment

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

For the functionality built in to dfx, it's okay to report the method name (notify_mint_cycles, create_batch). For user-specified method names, like dfx canister call <canister> <name>, we should report a placeholder rather than the actual name of the method. Something like literally <user-specified canister method>. The call site in this case is "calling the method that the user specified".

# explicit call
dfx_start
assert_command_fail dfx canister call ryjl3-tyaaa-aaaaa-aaaba-cai name
assert_command jq -se 'last | .replica_error_call_site == "name" and .replica_error_code == "IC0301"' "$log"

Choose a reason for hiding this comment

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

This test is the one that shows we're reporting data that we should not.

Suggested change
assert_command jq -se 'last | .replica_error_call_site == "name" and .replica_error_code == "IC0301"' "$log"
assert_command jq -se 'last | .replica_error_call_site == "<user-specified canister method>" and .replica_error_code == "IC0301"' "$log"

LocalNetworkScopeDescriptor::Shared { .. } => NetworkType::LocalShared,
}
} else {
NetworkType::UnknownUrl

Choose a reason for hiding this comment

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

Can we set this up so the only way NetworkType::UnknownUrl comes up is if something like --network <url> was passed (and did not turn out to be is_ic)?
UnknownConfigured should mean a network config entry with providers (as opposed to bind), also that didn't turn out to be is_ic.

Technically, network.r#type doesn't divide networks into some kind of taxonomy. This field more describes how the canister ids are managed. You could have a local network that is persistent (though I don't know why you would), or a network with providers that is ephemeral. The playground has its own special handling.

Here's an attempt at identification:

  • network.local_server_descriptor.is_some() - this is a local network. (comes from a config entry with bind)
  • network.r#type is Playground - it's the playground (note this will have is_ic set too)
  • network.is_ic - it's mainnet
  • was passed as a url to --network - UnknownUrl (would probably have to indicate this in create_url_based_network_descriptor())
  • UnknownConfigured otherwise (came from a config entry with providers, and did not turn out to be mainnet)

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