Skip to content

Conversation

@clouvet
Copy link
Collaborator

@clouvet clouvet commented Mar 8, 2025

Change Summary

What and Why:

This change fixes metrics not being sent in non-interactive sessions. The previous version of SendMetrics was failing in non-interactive environments because it was using the original context directly with HTTP requests, which could be canceled before metrics were successfully sent, resulting in abandoned requests and lost metrics data.

How:

The fix modifies the metrics system to:

  1. Refactor SendMetrics with proper HTTP request handling, error management, and response body cleanup
  2. Implement a 15-second timeout mechanism for non-interactive environments
  3. Ensure metrics collection failures don't block deployments by only logging warnings
  4. Properly establish fallback mechanisms for token authentication, dropping back to the access token or api token depending on availability

This ensures metrics are sent successfully in both interactive and non-interactive modes, with detailed logging for troubleshooting.

Related to:

#2974


Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

@clouvet clouvet requested a review from benbjohnson March 8, 2025 05:29
@clouvet clouvet force-pushed the collect-metrics-in-non-interactive-environments branch from c8bcd8b to d38af0a Compare March 11, 2025 04:38
@clouvet clouvet requested a review from benbjohnson March 11, 2025 04:39
Copy link
Contributor

@benbjohnson benbjohnson left a comment

Choose a reason for hiding this comment

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

lgtm overall, just one comment

@clouvet clouvet merged commit 46425b2 into master Mar 15, 2025
27 of 30 checks passed
@clouvet clouvet deleted the collect-metrics-in-non-interactive-environments branch March 15, 2025 04:13
clouvet added a commit that referenced this pull request Mar 15, 2025
clouvet added a commit that referenced this pull request Mar 18, 2025
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.

3 participants