From 5ec053eed5a00842d97fbc0c2be403a3129a85c2 Mon Sep 17 00:00:00 2001 From: Shairyar Baig Date: Wed, 3 Sep 2025 16:44:21 +0500 Subject: [PATCH] Add helpful message for 401 errors about app-level keys --- ...-to-know-if-wrong-api-key-is-being-used.md | 8 ++++++++ src/main.rs | 20 ++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 .changesets/make-it-easy-to-know-if-wrong-api-key-is-being-used.md diff --git a/.changesets/make-it-easy-to-know-if-wrong-api-key-is-being-used.md b/.changesets/make-it-easy-to-know-if-wrong-api-key-is-being-used.md new file mode 100644 index 0000000..3214679 --- /dev/null +++ b/.changesets/make-it-easy-to-know-if-wrong-api-key-is-being-used.md @@ -0,0 +1,8 @@ +--- +bump: patch +type: add +--- + +Show helpful error message for incorrect API key usage. + +When users encounter unauthorized errors, it will be easy for them to know they are using the wrong key. \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b817c58..5a97132 100644 --- a/src/main.rs +++ b/src/main.rs @@ -754,11 +754,21 @@ async fn send_batch( let response = client.post(url.clone()).body(batch_bytes).send().await?; - info!( - "Batch of {} metrics sent: {:?}", - batch.get_metrics().len(), - response.status() - ); + let status = response.status(); + + if status == 401 { + warn!( + "Batch of {} metrics failed to send: {:?} - Make sure you're using an app-level key", + batch.get_metrics().len(), + status + ); + } else { + info!( + "Batch of {} metrics sent: {:?}", + batch.get_metrics().len(), + status + ); + } Ok(response) }