-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat: Add new stdlib function to_json #2860
base: main
Are you sure you want to change the base?
Conversation
`encoding.to_json` fails if the map argument provided can't be parsed as json string. | ||
|
||
A common use case of `encoding.to_json` is to encode a config of component which is expected to be a JSON | ||
For example, `config` of a [`prometheus.exporter.blackbox`][] |
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.
For example, `config` of a [`prometheus.exporter.blackbox`][] | |
For example, configuration of a [`prometheus.exporter.blackbox`][] |
Missing a word here... a prometheus.exporter.blackbox
string?
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 wanted to refer the param name in the component updated accordingly.
a6e6e48
to
7ce2113
Compare
Fix documentation remove test
7ce2113
to
7189840
Compare
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.
Thanks, I agree that only supporting map is better and if users need another type we can always extend it later :)
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.
LGTM, thanks! Over to @clayton-cornell for another doc review
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.
Two small doc changes. If the question I have on line 70 is "it depends" then we can leave it as-is for now and just add the two missing .
on lines 69 and 70.
`encoding.to_json` fails if the input argument provided can't be parsed as JSON string. | ||
|
||
A common use case for `encoding.to_json` is to encode a configuration of component which is expected to be a JSON string | ||
For example, `config` param of [`prometheus.exporter.blackbox`][] |
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.
For example, `config` param of [`prometheus.exporter.blackbox`][] | |
For example, `config` param of [`prometheus.exporter.blackbox`][]. |
I'm not sure what "config
param" means in this context.
Can this be reworked as:
For example, a configuration parameter in [prometheus.exporter.blackbox
][].
Does this mean the same thing?
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.
prometheus.exporter.blackbox
component accepts a argument called config
which is expected to be a JSON string. May be changing the word param can be more appropriate I believe. https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.exporter.blackbox/#arguments
PR Description
Adds a new stdlib function for json encoding
to_json
which converts a map to JSONWhich issue(s) this PR fixes
Fixes #152
Notes to the Reviewer
PR Checklist