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

Support JSON marshalling interface #11816

Closed
jaronoff97 opened this issue Jan 5, 2023 · 2 comments
Closed

Support JSON marshalling interface #11816

jaronoff97 opened this issue Jan 5, 2023 · 2 comments

Comments

@jaronoff97
Copy link

Proposal

Right now, Prometheus only supports marshaling via YAML through the following interfaces:

  • yaml.Unmarshaler
  • yaml.Marshaler

This causes an issue for a user trying to serialize a scrape config to JSON as we try to do in the OpenTelemetry world here. Right now we have to serialize to YAML first, and then serialize that to JSON. Would it be welcome to add methods to prometheus scrape config fields (and their sub-fields) to adhere to the following interface

  • json.Marshaler
  • json.Unmarshaler
@roidelapluie
Copy link
Member

roidelapluie commented Jan 6, 2023

Thank you for your suggestion to add support for marshaling via JSON in Prometheus. I understand the need for this feature, and I agree that it would be useful for you to have the option to serialize configs to JSON.

However, I have to consider the complexity and maintenance burden of adding this feature. Currently, we only support marshaling via YAML, and adding support for JSON marshaling would require significant changes to the codebase. In addition, we do not support full marshaling even in YAML - secrets are not marshallable. Furthermore, the basic JSON marshaling in the prometheus/common package has proven to be more complex than expected, as demonstrated in this pull request: prometheus/common#394

Given these considerations, as well as our general preference to avoid adding dead code, I don't think we should support full marshaling to JSON at this time.

@alexgreenbank
Copy link
Member

Hello from the bug scrub.

Closing as this is almost 2 years old and there was no follow up to the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants