Skip to content

feat(logs): stateful gRPC log streaming with Rust pattern extraction#49342

Merged
DDuongNguyen merged 2 commits intologs-stateful-devfrom
yoon-dev
Apr 15, 2026
Merged

feat(logs): stateful gRPC log streaming with Rust pattern extraction#49342
DDuongNguyen merged 2 commits intologs-stateful-devfrom
yoon-dev

Conversation

@DDuongNguyen
Copy link
Copy Markdown
Contributor

Dev branch for Yoon's stateful encoding work. This contains the full feature set:

  • Token type system and Rust FFI tokenizer bridge (FlatBuffers)
  • Generic eviction framework
  • Pattern clustering, tag management, JSON preprocessor
  • gRPC stateful sender with pattern extraction and delta encoding
  • Pipeline integration and status reporting

See the stacked PRs for reviewable breakdown:

@DDuongNguyen DDuongNguyen force-pushed the yoon-dev branch 2 times, most recently from 691a8d4 to 57e962b Compare April 14, 2026 20:14
Implement a stateful gRPC transport for the logs agent that extracts
reusable patterns from log messages, reducing wire size by 5-10x for
high-volume pipelines.

Core components:
- gRPC stream worker with lifecycle management, backoff, and reconnection
- Protobuf-based stateful encoding (PatternDefine, StructuredLog, DictEntryDefine)
- Rust DFA tokenizer via FFI (FlatBuffers zero-copy deserialization)
- Drain-inspired clustering with typed tokens and signature hashing
- Dual-watermark eviction for patterns and tag dictionaries
- Delta encoding for timestamps, pattern IDs, and tags
- JSON preprocessing to extract structured fields
- Batch tokenization pipeline with non-blocking drain strategy

Performance optimizations:
- Hot-pattern O(1) cache for steady-state matching
- Saturation scoring to skip redundant merge checks
- Adaptive first-word protection with cardinality threshold
- Tag input fingerprint cache (zero-alloc on cache hit)
- Pre-allocated DynamicValue backing arrays
- Lazy dict promotion for high-cardinality wildcard values

Vendored pre-built libpatterns binaries (temporary, pending dd-source merge):
- linux/amd64, linux/arm64, darwin/arm64
# Conflicts:
#	pkg/logs/sender/grpc/batch_strategy.go
#	pkg/logs/sender/grpc/stream_worker.go
#	pkg/proto/datadog/stateful/stateful_encoding.proto
#	pkg/proto/pbgo/statefulpb/stateful_encoding.pb.go
#	tasks/agent.py
@DDuongNguyen DDuongNguyen merged commit 0c7cad9 into logs-stateful-dev Apr 15, 2026
1 check passed
@DDuongNguyen DDuongNguyen deleted the yoon-dev branch April 15, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant