-
Notifications
You must be signed in to change notification settings - Fork 320
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
Add methods to model.Duration for JSON marshalling and unmarshalling #280
Conversation
Add methods to model.Duration structs to allow them to be serialized and unserialized to/from JSON. This helps downstream consumers of the structs that attempt to use them in objects that are expected to be able to be represented as JSON (such as Cortex). Signed-off-by: Nick Pillitteri <[email protected]>
I am wondering why this works in Prometheus rules (yaml) but not json ? |
@roidelapluie I'm not sure I understand your question. |
Prometheus has an API page where we expose rules, it can also unmarshal this as yaml. However, we do not implement yamlUnmarshaller here .. so I wonder why json marshalling would be mandatory and not yaml marshalling |
YAML marshalling and unmarshalling (as well as text marshalling/unmarshalling) is implemented for this type in the same file: Line 270 in 47ee79a
|
Oh sorry I did not see it 👀 LGTM except one thing: can you make all the unmarshal functions look the same (look at how we manage the errors)? Just pick one patterm. |
Sure, will do |
Signed-off-by: Nick Pillitteri <[email protected]>
@roidelapluie Changes made but the CI seems to have failed for unrelated reasons. Thanks for all your help on this! |
Thanks! |
@56quarters do you need a release for this? |
@roidelapluie That'd be great if it's not too much trouble, thanks! |
v0.19.0 is out :) |
Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]>
Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]>
Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]>
Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]>
* Add BenchmarkIngesterV2Push So we can check the efficiency of changes to `v2Push()`. Broadly copied from `BenchmarkIngesterPush()`. Signed-off-by: Bryan Boreham <[email protected]> * Use TSDB's index of series, remove RefCache prometheus/prometheus#8600 adds a method to `TSDB.Appender` which allows us to save building a parallel cache, reducing ingester heap by about 20%. We depend on values from GetRef() remaining valid while v2Push() uses them. Currently the only way a ref can be invalidated is by a head compaction, which cannot happen while v2Push() holds the append lock. Signed-off-by: Bryan Boreham <[email protected]> * New version of GetRef() that returns labels Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]> * Add comment on use of copiedLabels Signed-off-by: Bryan Boreham <[email protected]> * Update to Prometheus main branch Pinned gRPC and other dependencies changed by the update in Prometheus to avoid taking so much change on this PR. Signed-off-by: Bryan Boreham <[email protected]>
* Add BenchmarkIngesterV2Push So we can check the efficiency of changes to `v2Push()`. Broadly copied from `BenchmarkIngesterPush()`. Signed-off-by: Bryan Boreham <[email protected]> * Use TSDB's index of series, remove RefCache prometheus/prometheus#8600 adds a method to `TSDB.Appender` which allows us to save building a parallel cache, reducing ingester heap by about 20%. We depend on values from GetRef() remaining valid while v2Push() uses them. Currently the only way a ref can be invalidated is by a head compaction, which cannot happen while v2Push() holds the append lock. Signed-off-by: Bryan Boreham <[email protected]> * New version of GetRef() that returns labels Now we only need to make a copy if GetRef() returns zero Note Prometheus update brings in JSON marshalling of model.Duration prometheus/common#280 Signed-off-by: Bryan Boreham <[email protected]> * Add comment on use of copiedLabels Signed-off-by: Bryan Boreham <[email protected]> * Update to Prometheus main branch Pinned gRPC and other dependencies changed by the update in Prometheus to avoid taking so much change on this PR. Signed-off-by: Bryan Boreham <[email protected]> Former-commit-id: ad3ea42
Enable Prometheus native histograms for request_duration_seconds
Add methods to model.Duration structs to allow them to be serialized
and unserialized to/from JSON. This helps downstream consumers of the
structs that attempt to use them in objects that are expected to be
able to be represented as JSON (such as Cortex).
An example in Cortex where this would help:
validation.Limits
Signed-off-by: Nick Pillitteri [email protected]