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) }