influxdata / influxdb-client-php

InfluxDB (v2+) Client Library for PHP
https://influxdata.github.io/influxdb-client-php/
MIT License
151 stars 47 forks source link

Try to convert non-string-tags to strings or throw an Exception #145

Closed mkrauser closed 10 months ago

mkrauser commented 1 year ago

Proposal: Try to convert non-string-tags to strings or throw an Exception

Current behavior: Right now, if non-string-values are added as tags those values are ignored silently, which is not very helpful.

Desired behavior: There are IMHO three non-exclusive options:

  1. Add a TypeHint to addTag. But this will not help, if the tags are passed to the constructor
  2. Check, if the value is a scalar or an Instance of Stringable (>= php 8.0) or an object with a __toString() function and convert such values to strings.
  3. Throw an exception or at least a warning for non string tags.

I will open a PR for this.

Alternatives considered: none

Use case: Ignoring non-string-tags silently may require manual debugging.