Create a SizedGenerator for use in OTel metrics#1355
Conversation
e4db940 to
e5b7497
Compare
87fa48b to
f24978e
Compare
e5b7497 to
9fbe654
Compare
f24978e to
e954798
Compare
9fbe654 to
ce2d61a
Compare
e954798 to
c631da0
Compare
1712dab to
96508d5
Compare
8dc968c to
04b3096
Compare
96508d5 to
c1d221c
Compare
04b3096 to
c0ed5ff
Compare
287106d to
0e2b5e0
Compare
1070aa3 to
30286ee
Compare
0e2b5e0 to
b240441
Compare
30286ee to
8f095f4
Compare
b240441 to
9fac6a2
Compare
8f095f4 to
9a1e8e2
Compare
9fac6a2 to
97b5d15
Compare
9a1e8e2 to
585b425
Compare
97b5d15 to
a586e7e
Compare
e3a8386 to
867ab2b
Compare
19b629a to
fb7a2b1
Compare
This commit attempts to address the payload generation issues -- blocks are too big to be useful, depending on user configuration -- by making the Generator aware of the byte budget. This is still failing tests as of this commit but it compiles. REF SMPTNG-659 Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
fb7a2b1 to
62c1fbf
Compare
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
62c1fbf to
7fe5e85
Compare
| use super::templates::GeneratorError; | ||
| use crate::{Error, Generator, common::config::ConfRange, common::strings::Pool}; | ||
| use opentelemetry_proto::tonic::common::v1::{AnyValue, KeyValue, any_value}; | ||
| use prost::Message; |
There was a problem hiding this comment.
I think you can remove this since you import in the test module
| pub(crate) fn fetch<R>( | ||
| &mut self, | ||
| rng: &mut R, | ||
| budget: &mut usize, |
There was a problem hiding this comment.
small suggestion for extra clarity
| budget: &mut usize, | |
| encoded_budget: &mut usize, |
|
|
||
| // Generate new instances until either context_cap is hit or the | ||
| // remaining space drops below our lookup interval. | ||
| if self.len < self.context_cap { |
There was a problem hiding this comment.
the goal here is to "lazily" generate new contexts when needed rather than doing it entirely up front, and it seems like part of that motivation is so that we can call generator.generate() with the "updated" limit and ensure that the templates are as useful as possible
| } | ||
| } | ||
|
|
||
| fn cut_data_points(metric: Metric) -> Metric { |
There was a problem hiding this comment.
looks like this may have some allocations involved, could this take a mutable reference and modify it in-place?
or if the lifetimes are hard, maybe use std::mem::take to steal the memory?
| /// Generate a new instance of `Self::Output`. Implementations MUST uphold | ||
| /// the following properties: | ||
| /// | ||
| /// * `budget` is decremented if and only if return is Ok |
There was a problem hiding this comment.
Non-blocking comment, but a suggestion for this API would be to return a tuple of Self::Output (the generated item) and usize (encoded size of generated item) and push this invariant up to the caller to do the accounting. Would slightly simplify the implementations of generate (which are already plenty complex)

What does this PR do?
This commit attempts to address the payload generation issues -- blocks
are too big to be useful, depending on user configuration -- by making the
Generator aware of the byte budget. This is still failing tests as of this
commit but it compiles.
Motivation
REF SMPTNG-659