dmolokanov/appinsights-rs

handle "Invalid instrumentation key" errors

Opened this issue · 2 comments

When an invalid instrumentation key is provided, appinsights-rs will happily continue to send records even though they should all be rejected.

This behavior can be seen using an invalid instrumentation key using the example clients:

[2021-10-01T15:23:40Z DEBUG reqwest::connect] starting new connection: https://dc.services.visualstudio.com/
[2021-10-01T15:23:40Z DEBUG reqwest::async_impl::client] response '400 Bad Request' for https://dc.services.visualstudio.com/v2/track
[2021-10-01T15:23:40Z DEBUG appinsights::transmitter] Unknown status: 400 Bad Request. {"itemsReceived":3,"itemsAccepted":0,"errors":[{"index":0,"statusCode":400,"message":"Invalid instrumentation key"},{"index":1,"statusCode":400,"message":"Invalid instrumentation key"},{"index":2,"statusCode":400,"message":"Invalid instrumentation key"}]}. Nothing to re-send

Hi @bmc-msft ! Thanks for reporting the issue! While it is a little annoying it is made by design. Since telemetry logs collected and sent in the background it cannot return an error during initialization process. Moreover someone can rotate key from appinsights while client is running, so the initialization is also not the place to handle this type of errors?

Is there a neat pattern to handle this type of errors we can leverage? I'm open to any suggestions.

I'm not sure of the right path, but it's more troublesome when an instrumentation key is never valid.