Struct vector_core::metrics::AgentDDSketch
source · pub struct AgentDDSketch { /* private fields */ }
Expand description
DDSketch implementation based on the Datadog Agent.
This implementation is subtly different from the open-source implementations of DDSketch
, as
Datadog made some slight tweaks to configuration values and in-memory layout to optimize it for
insertion performance within the agent.
We’ve mimicked the agent version of DDSketch
here in order to support a future where we can
take sketches shipped by the agent, handle them internally, merge them, and so on, without any
loss of accuracy, eventually forwarding them to Datadog ourselves.
As such, this implementation is constrained in the same ways: the configuration parameters cannot be changed, the collapsing strategy is fixed, and we support a limited number of methods for inserting into the sketch.
Importantly, we have a special function, again taken from the agent version, to allow us to interpolate histograms, specifically our own aggregated histograms, into a sketch so that we can emit useful default quantiles, rather than having to ship the buckets – upper bound and count – to a downstream system that might have no native way to do the same thing, basically providing no value as they have no way to render useful data from them.
Implementations§
source§impl AgentDDSketch
impl AgentDDSketch
sourcepub fn with_agent_defaults() -> Self
pub fn with_agent_defaults() -> Self
Creates a new AgentDDSketch
based on a configuration that is identical to the one used by
the Datadog agent itself.
sourcepub fn from_raw(
count: u32,
min: f64,
max: f64,
sum: f64,
avg: f64,
keys: &[i16],
counts: &[u16],
) -> Option<AgentDDSketch>
pub fn from_raw( count: u32, min: f64, max: f64, sum: f64, avg: f64, keys: &[i16], counts: &[u16], ) -> Option<AgentDDSketch>
Creates a new AgentDDSketch
based on the given inputs.
This is only useful for constructing a sketch from the raw components when the sketch has passed through the transform boundary into Lua/VRL and needs to be reconstructed.
This is a light code smell, as our intention is to rigorously mediate access and mutation of
a sketch through AgentDDSketch
and the provided methods.
pub fn gamma(&self) -> f64
pub fn bin_index_offset(&self) -> i32
pub fn bins(&self) -> &[Bin]
pub fn bin_map(&self) -> BinMap
pub fn config(&self) -> &Config
sourcepub fn min(&self) -> Option<f64>
pub fn min(&self) -> Option<f64>
Minimum value seen by this sketch.
Returns None
if the sketch is empty.
sourcepub fn max(&self) -> Option<f64>
pub fn max(&self) -> Option<f64>
Maximum value seen by this sketch.
Returns None
if the sketch is empty.
sourcepub fn sum(&self) -> Option<f64>
pub fn sum(&self) -> Option<f64>
Sum of all values seen by this sketch.
Returns None
if the sketch is empty.
sourcepub fn avg(&self) -> Option<f64>
pub fn avg(&self) -> Option<f64>
Average value seen by this sketch.
Returns None
if the sketch is empty.
pub fn insert(&mut self, v: f64)
pub fn insert_many(&mut self, vs: &[f64])
pub fn insert_n(&mut self, v: f64, n: u32)
sourcepub fn insert_interpolate_buckets(
&mut self,
buckets: Vec<Bucket>,
) -> Result<(), &'static str>
pub fn insert_interpolate_buckets( &mut self, buckets: Vec<Bucket>, ) -> Result<(), &'static str>
§Errors
Returns an error if a bucket size is greater that u32::MAX
.
pub fn quantile(&self, q: f64) -> Option<f64>
sourcepub fn merge(&mut self, other: &AgentDDSketch) -> Result<(), MergeError>
pub fn merge(&mut self, other: &AgentDDSketch) -> Result<(), MergeError>
Merges another sketch into this sketch, without a loss of accuracy.
All samples present in the other sketch will be correctly represented in this sketch, and summary statistics such as the sum, average, count, min, and max, will represent the sum of samples from both sketches.
§Errors
If there is an error while merging the two sketches together, an error variant will be returned that describes the issue.
sourcepub fn transform_to_sketch(metric: Metric) -> Result<Metric, &'static str>
pub fn transform_to_sketch(metric: Metric) -> Result<Metric, &'static str>
Converts a Metric
to a sketch representation, if possible, using AgentDDSketch
.
For certain types of metric values, such as distributions or aggregated histograms, we can
easily convert them to a sketch-based representation. Rather than push the logic of how to
do that up to callers that wish to use a sketch-based representation, we bundle it here as a
free function on AgentDDSketch
itself.
If the metric value cannot be represented as a sketch – essentially, everything that isn’t a distribution or aggregated histogram – then the metric is passed back unmodified. All existing metadata – series name, tags, timestamp, etc – is left unmodified, even if the metric is converted to a sketch internally.
§Errors
Returns an error if a bucket size is greater that u32::MAX
.
Trait Implementations§
source§impl ByteSizeOf for AgentDDSketch
impl ByteSizeOf for AgentDDSketch
source§impl Clone for AgentDDSketch
impl Clone for AgentDDSketch
source§fn clone(&self) -> AgentDDSketch
fn clone(&self) -> AgentDDSketch
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Configurable for AgentDDSketch
impl Configurable for AgentDDSketch
source§fn referenceable_name() -> Option<&'static str>
fn referenceable_name() -> Option<&'static str>
source§fn generate_schema(
schema_gen: &RefCell<SchemaGenerator>,
) -> Result<SchemaObject, GenerateError>
fn generate_schema( schema_gen: &RefCell<SchemaGenerator>, ) -> Result<SchemaObject, GenerateError>
§fn is_optional() -> boolwhere
Self: Sized,
fn is_optional() -> boolwhere
Self: Sized,
§fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
§fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
source§impl Debug for AgentDDSketch
impl Debug for AgentDDSketch
source§impl<'de> Deserialize<'de> for AgentDDSketch
impl<'de> Deserialize<'de> for AgentDDSketch
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<AgentDDSketch> for MetricValue
impl From<AgentDDSketch> for MetricValue
source§fn from(ddsketch: AgentDDSketch) -> Self
fn from(ddsketch: AgentDDSketch) -> Self
source§impl From<AgentDDSketch> for Sketch
impl From<AgentDDSketch> for Sketch
source§fn from(ddsketch: AgentDDSketch) -> Self
fn from(ddsketch: AgentDDSketch) -> Self
source§impl PartialEq for AgentDDSketch
impl PartialEq for AgentDDSketch
source§impl Serialize for AgentDDSketch
impl Serialize for AgentDDSketch
source§impl ToValue for AgentDDSketch
impl ToValue for AgentDDSketch
impl Eq for AgentDDSketch
Auto Trait Implementations§
impl Freeze for AgentDDSketch
impl RefUnwindSafe for AgentDDSketch
impl Send for AgentDDSketch
impl Sync for AgentDDSketch
impl Unpin for AgentDDSketch
impl UnwindSafe for AgentDDSketch
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
§fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more