You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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
The text was updated successfully, but these errors were encountered: