Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased
- Updated to rand 0.10.x
- Widened `scopes_per_resource` and `metrics_per_scope` in the OpenTelemetry metrics `Contexts` config from `u8` to `u16`, raising the per-emission cardinality ceiling from 65,025 to ~4.3B unique metric sites.

## [0.32.0]
## Changed
Expand Down
48 changes: 24 additions & 24 deletions lading_payload/src/opentelemetry/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ pub struct Contexts {
/// The range of attributes for resources.
pub attributes_per_resource: ConfRange<u8>,
/// The range of scopes that will be generated per resource.
pub scopes_per_resource: ConfRange<u8>,
pub scopes_per_resource: ConfRange<u16>,
/// The range of attributes for each scope.
pub attributes_per_scope: ConfRange<u8>,
/// The range of metrics that will be generated per scope.
pub metrics_per_scope: ConfRange<u8>,
pub metrics_per_scope: ConfRange<u16>,
/// The range of attributes for each metric.
pub attributes_per_metric: ConfRange<u8>,
}
Expand Down Expand Up @@ -238,15 +238,15 @@ impl Config {
ConfRange::Constant(m) => u32::from(m),
ConfRange::Inclusive { min, .. } => u32::from(min),
};
u32::from(n) * metrics
u32::from(n).saturating_mul(metrics)
}
ConfRange::Inclusive { min, .. } => {
let metrics = match self.contexts.metrics_per_scope {
ConfRange::Constant(0) => 0u32,
ConfRange::Constant(m) => u32::from(m),
ConfRange::Inclusive { min, .. } => u32::from(min),
};
u32::from(min) * metrics
u32::from(min).saturating_mul(metrics)
}
};

Expand All @@ -258,15 +258,15 @@ impl Config {
ConfRange::Constant(m) => u32::from(m),
ConfRange::Inclusive { max, .. } => u32::from(max),
};
u32::from(n) * metrics
u32::from(n).saturating_mul(metrics)
}
ConfRange::Inclusive { max, .. } => {
let metrics = match self.contexts.metrics_per_scope {
ConfRange::Constant(0) => 0u32,
ConfRange::Constant(m) => u32::from(m),
ConfRange::Inclusive { max, .. } => u32::from(max),
};
u32::from(max) * metrics
u32::from(max).saturating_mul(metrics)
}
};

Expand Down Expand Up @@ -556,9 +556,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
steps in 1..u8::MAX,
) {
Expand Down Expand Up @@ -599,9 +599,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
steps in 1..u8::MAX,
budget in 128..2048_usize,
Expand Down Expand Up @@ -647,9 +647,9 @@ mod test {
total_contexts_min in 1..4_u32,
total_contexts_max in 5..100_u32,
attributes_per_resource in 0..25_u8,
scopes_per_resource in 1..10_u8,
scopes_per_resource in 1..10_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 1..10_u8,
metrics_per_scope in 1..10_u16,
attributes_per_metric in 0..100_u8,
budget in 128..2048_usize,
) {
Expand Down Expand Up @@ -693,9 +693,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
budget in SMALLEST_PROTOBUF..2048_usize,
) {
Expand Down Expand Up @@ -767,9 +767,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
steps in 1..u8::MAX,
budget in SMALLEST_PROTOBUF..2048_usize,
Expand Down Expand Up @@ -912,9 +912,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 1..20_u8,
scopes_per_resource in 1..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 1..20_u8,
metrics_per_scope in 1..20_u16,
attributes_per_metric in 0..10_u8,
budget in SMALLEST_PROTOBUF..4098_usize,
) {
Expand Down Expand Up @@ -958,9 +958,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
steps in 1..u8::MAX,
budget in SMALLEST_PROTOBUF..2048_usize,
Expand Down Expand Up @@ -1041,9 +1041,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
budget in SMALLEST_PROTOBUF..4098_usize,
) {
Expand Down Expand Up @@ -1081,9 +1081,9 @@ mod test {
seed: u64,
total_contexts in 1..1_000_u32,
attributes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u8,
scopes_per_resource in 0..20_u16,
attributes_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u8,
metrics_per_scope in 0..20_u16,
attributes_per_metric in 0..10_u8,
budget in SMALLEST_PROTOBUF..512_usize, // see note below about repetition
) {
Expand Down
4 changes: 2 additions & 2 deletions lading_payload/src/opentelemetry/metric/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub(crate) enum Kind {

#[derive(Clone, Debug)]
pub(crate) struct ScopeTemplateGenerator {
metrics_per_scope: ConfRange<u8>,
metrics_per_scope: ConfRange<u16>,
metric_generator: MetricTemplateGenerator,
str_pool: Rc<strings::RandomStringPool>,
tags: TagGenerator,
Expand Down Expand Up @@ -404,7 +404,7 @@ impl<'a> crate::SizedGenerator<'a> for ScopeTemplateGenerator {

#[derive(Clone, Debug)]
pub(crate) struct ResourceTemplateGenerator {
scopes_per_resource: ConfRange<u8>,
scopes_per_resource: ConfRange<u16>,
attributes_per_resource: ConfRange<u8>,
scope_generator: ScopeTemplateGenerator,
tags: TagGenerator,
Expand Down
Loading