Skip to content

Comments

Add error to metrics#2719

Merged
felipemadero merged 13 commits intomainfrom
metrics-test-javier
Apr 7, 2025
Merged

Add error to metrics#2719
felipemadero merged 13 commits intomainfrom
metrics-test-javier

Conversation

@felipemadero
Copy link
Collaborator

Why this should be merged

Current CLI metrics don't collect information on failed commands. This PR add err message collection
in a new field, error.

How this works

How this was tested

How is this documented

Comment on lines +100 to +102
if telemetryToken == "" && !utils.IsE2E() {
app.Log.Warn("no token is configured for sending metrics")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to users to see this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is only going into avalanche.log, not stdout. it is useful for debugging. not expected to be printed on releases.

Comment on lines +106 to +109
client, err := posthog.NewWithConfig(telemetryToken, posthog.Config{Endpoint: telemetryInstance})
if err != nil {
app.Log.Warn(fmt.Sprintf("failure creating metrics client: %s", err))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, why not just print nothing to logs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is only going into avalanche.log, not stdout. we are seeing that not all events seem to be sent, so we need to have some logs on this, so we can see if something is happening and maybe try again based on the error

Comment on lines +140 to +144
if err := client.Enqueue(event); err != nil {
app.Log.Warn(fmt.Sprintf("failure sending metrics %#v: %s", telemetryProperties, err))
}
if err := client.Close(); err != nil {
app.Log.Warn(fmt.Sprintf("failure closing metrics client %#v: %s", telemetryProperties, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is only going into avalanche.log, not stdout. we are seeing that not all events seem to be sent, so we need to have some logs on this, so we can see if something is happening and maybe try again based on the error

flags map[string]string,
err error,
) {
if sent {
Copy link
Contributor

Choose a reason for hiding this comment

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

if user calls command 1, sent will be set to true after tracking info is sent. What about when user calls command 2, since sent would have been set to true here, will the tracking info be sent?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess best way to test this is see if we can see the second command on the dashboard after first command is called

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that variable is set per execution. a new execution of CLI with starts with the value set to false.

@github-project-automation github-project-automation bot moved this from Backlog 🗄️ to In Review 👀 in avalanchego Apr 7, 2025
@felipemadero felipemadero merged commit 6efaba5 into main Apr 7, 2025
41 of 42 checks passed
@felipemadero felipemadero deleted the metrics-test-javier branch April 7, 2025 18:41
@github-project-automation github-project-automation bot moved this from In Review 👀 to Done ✅ in avalanchego Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants