influxdata / influxdb-csharp

A .NET library for efficiently sending points to InfluxDB 1.x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logging to a database that doesn't exist fails silently

liamdawson opened this issue · comments

I've been trying the netstandard13 version of this lib, and was confused why Grafana wasn't able to find the stats that I'd been collecting. Once I created the db I was logging to, it worked as expected.

I would have expected to get an exception when logging to a database that does not exist (and a "create database if it doesn't exist" option on the MetricsCollector would be awesome, as well). If an exception isn't possible, it might at least be worth logging as a troubleshooting tip somewhere. 😄

Hmm, that's definitely not a good experience!

The problem is that we try to guarantee that emitting metrics via the collector never raises an exception. Often we can't raise an exception at the callsite too, such as when batching. Instead there is CollectorLog.RegisterErrorHandler which allows you to subscribe to errors within the pipeline. If you hook this up, you'll see an error message.

I had a quick test however and although you do get an error event - the message is just "InternalServerError Internal Server Error", which is not great and thats definitely something that should be improved, perhaps by proving a richer Exception object in addition to the message.

I wonder if we've got a documentation/discoverability problem here. CollectorLog isn't mentioned within the readme, so discovering it is pretty hard. Another option, as discussed in #22 is to also have an error reporting method on the CollectorConfiguration which allows you to hookup an error handler early on for your specific Collector.

Let's get that guarantee documented! It's great to know that it's expected to work that way. Perhaps adding it as an extension method at the configuration level would make it discoverable for those that explore via intellisense, which would have helped me. 😄