Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[influxdb] Add option for using metadata value as measurement name #9943

Merged
merged 16 commits into from
Mar 21, 2021
Merged

[influxdb] Add option for using metadata value as measurement name #9943

merged 16 commits into from
Mar 21, 2021

Conversation

DerOetzi
Copy link
Contributor

Add option for using the metadata value as measurement name. Part of solution for #9556

Signed-off-by: Johannes Ott info@johannes-ott.net

@DerOetzi DerOetzi requested a review from lujop as a code owner January 24, 2021 16:15
Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @DerOetzi
But I see some problems with this because it will break the query part of the addon:

  • A complete solution should add also itemName as a tag when this option is used and make query part intelligent to use that logic.
  • Also I would like to include test covering that new functionality.
  • I added also some minor notes in your code

Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes explained in previous comment

@DerOetzi
Copy link
Contributor Author

Thanks for your contribution @DerOetzi
But I see some problems with this because it will break the query part of the addon:

  • A complete solution should add also itemName as a tag when this option is used and make query part intelligent to use that logic.

The itemname is already always included as tag, if I see this correct. But your right I missed the query part. Please review my changes on this.

  • Also I would like to include test covering that new functionality.

I have added some tests. Please give me feedback, whether they are enough like this.

  • I added also some minor notes in your code

Renamed the things you commented

@DerOetzi DerOetzi requested a review from lujop January 27, 2021 15:55
Copy link
Member

@Hilbrand Hilbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @lujop Can you have a second look at this pull request and approve if ok.

Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your modifications, I haven't had time to test but it seems ok.
Only two minor things.

@DerOetzi
Copy link
Contributor Author

I did some refactoring of my code as mentioned above there is no configuration flag for service anymore, but it just checks whether there is a metadata value or not.

But while doing the refactoring I think I have found a bug inside the existing code, of ItemToStorePointCreator which wasn't noticed because of a missing test case. But I'm not sure and need your experience with the code @lujop and @Hilbrand.

At the InfluxFilterCriteriaQueryCreatorImplTest.java there is a testcase testEscapeSimpleItem which test an item with a dot in its name. This one fails now with an IllegalArgumentException when trying to generate MetadataKey from item name.

I have added now such testcase to the ItemToStorePointCreator file as well, which fails although with the old code, without my changes because it tries to access MetadataKey in addPointTags as well.

My question is it a valid item name with a dot, then the question is how to access metadata with such items, or is this testcase invalid in the FilterQuery test?

@DerOetzi
Copy link
Contributor Author

I did some further research from what I see so far an item name cannot contain a dot because this will always fail here:

https://github.com/openhab/openhab-core/blob/029280683087d07d3d52bc1b125e73c17a33917a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/AbstractUID.java#L96

So I think the testcase is not valid and I would remove it?

@DerOetzi
Copy link
Contributor Author

@lujop and @Hilbrand removed the testcase for item name with dot

Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, I apologize for not being able to review the addon before.
Today I've been able to build and test it for InfluxDB 2 and worked correctly.

The code seems good to me also.
I only made a little commit with some minor documentation changes and suggested a change in a condition expanding the negation to make reading the condition clearer. Please accept the commit suggestion.

Good work, and thank you very much for the PR.

Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the unused parameter from config.

Johannes Ott and others added 13 commits February 27, 2021 22:41
Signed-off-by: Johannes Ott <info@johannes-ott.net>
…y builder to find data in correct measurement. Add tests for new feature.

Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
…-INF/config/config.xml

Co-authored-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
…nhab/persistence/influxdb/internal/influx1/Influx1FilterCriteriaQueryCreatorImpl.java

Co-authored-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
@DerOetzi
Copy link
Contributor Author

First of all, I apologize for not being able to review the addon before.
Today I've been able to build and test it for InfluxDB 2 and worked correctly.

The code seems good to me also.
I only made a little commit with some minor documentation changes and suggested a change in a condition expanding the negation to make reading the condition clearer. Please accept the commit suggestion.

Good work, and thank you very much for the PR.

Thanks for your constructive review comments. Think we found a good solution together now.

Johannes Ott added 2 commits February 27, 2021 23:10
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
@DerOetzi
Copy link
Contributor Author

Please don't merge yet I think I have found another problem on restoring item states

Signed-off-by: Johannes Ott <info@johannes-ott.net>
@DerOetzi
Copy link
Contributor Author

Please don't merge yet I think I have found another problem on restoring item states

@lujop can you please recheck my last changes to V1 Query parts. As I noticed there was a bug because tem-tags where not accquired.

@lujop
Copy link
Contributor

lujop commented Feb 28, 2021

Please don't merge yet I think I have found another problem on restoring item states

@lujop can you please recheck my last changes to V1 Query parts. As I noticed there was a bug because tem-tags where not accquired.

Sure, let me find some time and I will install InfluxDB1 and do some more detailed testing

@DerOetzi
Copy link
Contributor Author

Please don't merge yet I think I have found another problem on restoring item states

@lujop can you please recheck my last changes to V1 Query parts. As I noticed there was a bug because tem-tags where not accquired.

Sure, let me find some time and I will install InfluxDB1 and do some more detailed testing

I have installed a v1.8 docker container and did some more testing myself. For me everything seems to work fine now, but I would be very glad, if find the time to check it as well @lujop

Copy link
Contributor

@lujop lujop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done some testing with InfluxDB1 and it seems to be working correctly.
Thanks for the fixs.

@lujop
Copy link
Contributor

lujop commented Mar 5, 2021

@Hilbrand It seems ok to be integrated for me.

@DerOetzi
Copy link
Contributor Author

@Hilbrand and @lujop is there any problem with this PR? Why isn't it merged yet?

@kaikreuzer
Copy link
Member

As @Hilbrand already approved on Feb 3, I'd say we can merge. 👍

@kaikreuzer kaikreuzer merged commit cdd99c9 into openhab:main Mar 21, 2021
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature for an existing add-on label Mar 21, 2021
@kaikreuzer kaikreuzer added this to the 3.1 milestone Mar 21, 2021
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
…penhab#9943)

* Add option for using metadata value as measurement name

Also-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
…penhab#9943)

* Add option for using metadata value as measurement name

Also-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
…penhab#9943)

* Add option for using metadata value as measurement name

Also-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…penhab#9943)

* Add option for using metadata value as measurement name

Also-by: Joan Pujol <joanpujol@gmail.com>
Signed-off-by: Johannes Ott <info@johannes-ott.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants