-
Notifications
You must be signed in to change notification settings - Fork 211
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
Prototype targets.merge function (array.combine_maps) #1826
Conversation
I wonder on the naming, the name makes me feel like its very SQL like and should behave like a SQL inner join. |
64767f2
to
b248d1c
Compare
@mattdurham Good point - I renamed it from "inner_join" to "merge". I also changed the namespace from "map" to "targets", because I realised that even "map" is not an appropriate namespace for this function as it operates on arrays of maps. |
Overall looks good! Though the complexity of this feels like it borders on a component, which means we could use the live debugging and mark as experimental. Since this has become specific to targets thoughts to add it to relabel.discovery? |
b248d1c
to
2c5dea2
Compare
@mattdurham The main reasons for having it as an std lib function are:
I do agree that there would be benefits to the component approach:
We could do a few things to make the std function a more compelling option:
In the long term, we could also:
cc @thampiotr he made the original suggestion to use std lib. |
2c5dea2
to
0ef415c
Compare
Maybe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there could be a way to get live debugging for stdlib functions?
In the Alloy UI, users can see the arguments and exports so they should already have the possibility to see the inputs and the output of the merge function. It's not live but seeing the latest values should be good enough. Live debugging is activated per component (you click on a button in the component page to open the stream of data). I'm not sure how it would look like in the UI to have it for a function that's inside a component. Implementation wise it's also not trivial. The functions are defined in the syntax pkg which should not depend on a particular Alloy feature. We would need some kind of wrapper that plugs the live debugging and runs because it needs to be able to enable/disable the stream depending on user input |
…make is more permissive and add tests
955fc04
to
96798db
Compare
@@ -44,6 +45,8 @@ v1.5.0-rc.0 | |||
- (_Experimental_) Add a `prometheus.write.queue` component to add an alternative to `prometheus.remote_write` | |||
which allowing the writing of metrics to a prometheus endpoint. (@mattdurham) | |||
|
|||
- (_Experimental_) Add the function `arrary.combine_maps` to the stdlib. (@ptodev, @wildum) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding it directly to the rc changelog to avoid another PR to main to switch it when we patch it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Left some comments and would like to take it for a spin. With some more tests and docs I think we can land this.
syntax/internal/value/value.go
Outdated
case TypeNull: | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this have some weird side-effects, like Len() called on null capsule or sth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this. Looking at the code, I don't think that this can be triggered because the type is checked before every call to Len. Maybe Paulin made this change before checking the types and then forgot about it or I'm missing something
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Piotr <[email protected]>
47d088d
to
5279bb4
Compare
* Prototype map.inner_join function * Rename to "targets.merge", remove unnecessary params * Add failure tests * Delete incorrect comment * rename targets.merge to array.combine_maps, mark it as experimental, make is more permissive and add tests * update changelog * Update CHANGELOG.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * rename mapCombine to combineMaps * document panic * add equal test * add more tests * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * add examples in doc * fix error propagation * remove value nul on len function * refactor code into a traversal function * update doc to avoid modifying the experimental shared doc --------- Co-authored-by: William Dumont <[email protected]> Co-authored-by: Piotr <[email protected]>
* update changelog version * Prototype targets.merge function (array.combine_maps) (#1826) * Prototype map.inner_join function * Rename to "targets.merge", remove unnecessary params * Add failure tests * Delete incorrect comment * rename targets.merge to array.combine_maps, mark it as experimental, make is more permissive and add tests * update changelog * Update CHANGELOG.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * rename mapCombine to combineMaps * document panic * add equal test * add more tests * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * add examples in doc * fix error propagation * remove value nul on len function * refactor code into a traversal function * update doc to avoid modifying the experimental shared doc --------- Co-authored-by: William Dumont <[email protected]> Co-authored-by: Piotr <[email protected]> * Implement an initial version of the support bundle in Alloy (#2009) * Implement an initial version of the support bundle in Alloy * Add documentation for support bundle * Update changelog * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Initial PR feedback * Rewrite http service to use logging library internal to alloy * Revert accidental commit of e2e test changes * Fix comment on exported function * Clean up added host variable that is no longer used * Refactor usage of logger in http service * Update internal/service/http/http.go Co-authored-by: Piotr <[email protected]> * implement PR feedback * Hide support bundle behind public preview stability level * Update docs based on feedback * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/troubleshoot/support_bundle.md Co-authored-by: Clayton Cornell <[email protected]> * More PR feedback in docs * Fix race condition in logger * Add a note about backward-compatibility exception --------- Co-authored-by: Clayton Cornell <[email protected]> Co-authored-by: Piotr <[email protected]> --------- Co-authored-by: Paulin Todev <[email protected]> Co-authored-by: William Dumont <[email protected]> Co-authored-by: Sam DeHaan <[email protected]> Co-authored-by: Clayton Cornell <[email protected]>
* Prototype map.inner_join function * Rename to "targets.merge", remove unnecessary params * Add failure tests * Delete incorrect comment * rename targets.merge to array.combine_maps, mark it as experimental, make is more permissive and add tests * update changelog * Update CHANGELOG.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * Update docs/sources/reference/stdlib/array.md Co-authored-by: Piotr <[email protected]> * rename mapCombine to combineMaps * document panic * add equal test * add more tests * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * Update syntax/internal/stdlib/stdlib.go Co-authored-by: Piotr <[email protected]> * add examples in doc * fix error propagation * remove value nul on len function * refactor code into a traversal function * update doc to avoid modifying the experimental shared doc --------- Co-authored-by: William Dumont <[email protected]> Co-authored-by: Piotr <[email protected]>
I hope this can enable users to decorate prometheus.exporter metrics with labels from discovery components.
The config could look like this:
Which issue(s) this PR fixes
Fixes #1443