Skip to content

Commit 6cdf9d6

Browse files
authored
Fix telemetry reporting for release builds (#2445)
1 parent 3698f52 commit 6cdf9d6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,8 @@ speculoos = { workspace = true }
249249
tower-test = { workspace = true }
250250
tracing-test = { workspace = true }
251251
temp-env = { version = "=0.3.6", features = ["async_closure"] }
252+
253+
# For sputnik, run tests with debug_assertions disabled. This is necessary because telemetry is not sent if
254+
# debug_assertions is enabled, and the tests rely on telemetry being sent to mock APIs.
255+
[profile.test.package.sputnik]
256+
debug-assertions = false

crates/sputnik/src/session.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use std::time::Duration;
1717

1818
use crate::{Report, SputnikError};
1919

20-
// set timeout to 100 ms to prevent blocking for too long on reporting; 30ms p99
21-
const REPORT_TIMEOUT: Duration = Duration::from_millis(100);
20+
/// Timeout for reporting telemetry. Note that this includes the entire time to make the request
21+
/// and receive the response, including on the client side. This is not just the server latency.
22+
const REPORT_TIMEOUT: Duration = Duration::from_millis(500);
2223

2324
/// The Session represents a usage of the CLI analogous to a web session
2425
/// It contains the "url" (command path + flags) but doesn't contain any
@@ -141,8 +142,9 @@ impl Session {
141142
/// sends anonymous usage data to the endpoint defined in ReportingInfo.
142143
pub async fn report(&self) -> Result<(), SputnikError> {
143144
// TODO: consider whether we want to disable non-production telemetry or at least document
144-
// the reasoning for not using it
145-
if !cfg!(debug_assertions) && !cfg!(test) {
145+
// the reasoning for not using it
146+
if cfg!(debug_assertions) {
147+
tracing::debug!("Skipping telemetry reporting");
146148
return Ok(());
147149
}
148150
if self.reporting_info.is_telemetry_enabled {

0 commit comments

Comments
 (0)