Warn on measurement starting with hashtags
Proposal: Warn when a measurement name starts with a #.
Current behavior: When a measurement starts with #, it is silently ignored. When such a name is written in the line protocol, this line is ignored since the # at the start of a line marks a comment.
Desired behavior: Either find a way to escape the # or warn that such a measurement cannot be used.
Use case: We have measurement names generated from data that can start with a #. The behavior that they are just missing is confusing and we didn't register it at first.
Hi @NicholasTNG,
thanks for using our client.
We will take a look.
Regards
It looks like ignoring comments is documented as part of the Line Protocol format.
@bednar Were you thinking of adding a helper function, similar to _append_default_tags to loop through the data and check the measurement name? Or document this?
@bednar Were you thinking of adding a helper function, similar to
_append_default_tagsto loop through the data and check the measurement name? Or document this?
We can document this in write method:
- https://github.com/influxdata/influxdb-client-python/blob/c06cb788db241bfc46c6dce3b2a084ef4b866017/influxdb_client/client/write_api_async.py#L42
- https://github.com/influxdata/influxdb-client-python/blob/c06cb788db241bfc46c6dce3b2a084ef4b866017/influxdb_client/client/write_api.py#L276
and also add warning into:
- https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/_base.py#L452
- https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/write_api.py#L419
something like:
if record.startswith("#"):
logger.warn(...)
@NicholasTNG - were you passing write a string? Or using some other method to produce data like the Point helper class, using a dictionary, etc?
I am good with adding this to the docs, my concern is adding a warning to only the strings if it doesn't help all the other various ways to write points.
We passed the data as a dictionary. I think this problem will occur with any way of producing the data since all of them are transformed into the line protocol in the end.
I haven't tested this, but I could also imagine that there a problems when you have a measurement starting with _, since Influx reserves those for internal use.
Thanks for the library :-)