#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct OtlpIngestLimits {
pub(crate) max_source_bytes: u64,
pub(crate) max_decoded_bytes: u64,
pub(crate) max_nesting_depth: u64,
pub(crate) max_span_count: u64,
pub(crate) max_attribute_count: u64,
pub(crate) max_attribute_key_bytes: u64,
pub(crate) max_attribute_value_bytes: u64,
}
pub(crate) const MAX_SUPPORTED_NESTING_DEPTH: u64 = 126;
impl OtlpIngestLimits {
pub(crate) fn corpus_v0() -> Self {
Self {
max_source_bytes: 64 * 1024,
max_decoded_bytes: 64 * 1024,
max_nesting_depth: 16,
max_span_count: 128,
max_attribute_count: 64,
max_attribute_key_bytes: 256,
max_attribute_value_bytes: 512,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum OtlpLimitDimension {
SourceBytes,
DecodedBytes,
NestingDepth,
SpanCount,
AttributeCount,
AttributeKeyBytes,
AttributeValueBytes,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum ShapeSite {
Root,
ResourceSpans,
ResourceSpansEntry,
Resource,
ScopeSpans,
ScopeSpansEntry,
InstrumentationScope,
Spans,
Span,
AttributeList,
AttributeEntry,
AttributeValue,
Status,
SkippedContainer,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SpanField {
TraceId,
SpanId,
ParentSpanId,
Kind,
StatusCode,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum RecognizedAttribute {
MethodName,
ResourceUri,
SessionId,
OperationName,
ToolName,
RequestId,
ErrorType,
RpcResponseStatusCode,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub(crate) enum OtlpIngestError {
#[error("exceeded {dimension:?} limit of {limit}")]
LimitExceeded {
dimension: OtlpLimitDimension,
limit: u64,
},
#[error("source truncated before the document ended")]
TruncatedSource,
#[error("malformed JSON document")]
MalformedJson,
#[error("unexpected shape at {0:?}")]
UnexpectedShape(ShapeSite),
#[error("duplicate member at {0:?}")]
DuplicateField(ShapeSite),
#[error("duplicate attribute key")]
DuplicateAttributeKey,
#[error("conflicting attribute value members")]
ConflictingAttributeValue,
#[error("missing required span field {0:?}")]
MissingRequiredSpanField(SpanField),
#[error("missing required recognized attribute {0:?}")]
MissingRequiredAttribute(RecognizedAttribute),
#[error("malformed span field {0:?}")]
MalformedSpanField(SpanField),
#[error("recognized attribute {0:?} has unsupported value type")]
RecognizedAttributeWrongType(RecognizedAttribute),
#[error("source read failed")]
Io,
#[error("unsupported {dimension:?} configuration; supported maximum is {supported_max}")]
UnsupportedLimitConfiguration {
dimension: OtlpLimitDimension,
supported_max: u64,
},
}