influxdb-client-python icon indicating copy to clipboard operation
influxdb-client-python copied to clipboard

Warn on measurement starting with hashtags

Open NicholasTNG opened this issue 3 years ago • 5 comments

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.

NicholasTNG avatar Jul 25 '22 07:07 NicholasTNG

Hi @NicholasTNG,

thanks for using our client.

We will take a look.

Regards

bednar avatar Jul 25 '22 11:07 bednar

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?

powersj avatar Aug 02 '22 13:08 powersj

@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?

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(...)

bednar avatar Aug 03 '22 05:08 bednar

@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.

powersj avatar Aug 05 '22 18:08 powersj

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

NicholasTNG avatar Aug 08 '22 06:08 NicholasTNG