feat(common): allocation-free tag validation and parsing - #2329
feat(common): allocation-free tag validation and parsing#2329morrisonlevi wants to merge 2 commits into
Conversation
Add typed tag validation errors and a borrowed iterator for tag lists. Reuse them internally while preserving existing constructors, return types, and error messages.
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: e1489d3 | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
BenchmarksComparisonBenchmark execution time: 2026-08-07 05:43:06 Comparing candidate commit e1489d3 in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 138 metrics, 0 unstable metrics.
|
What does this PR do?
Adds typed tag validation errors and a borrowed iterator for tag lists.
Motivation
In the OTel process and context work in PHP, we are now going to be making tags on every sample. I'm working to avoid allocations, or delay them until later if feasible. Right now there's no room because the only validation APIs are to actually make a tag. These new APIs let us validate
key:value,value, andDD_TAGSstyle tags all without allocating.Additional Notes
These new APIs are consumed internally so they aren't dead code either, except for validating a
(key, value)pair. The reason is that the way it is technically implemented in the constructor is toformat!("{key}:{value}")and then use the serializedkey:valuevalidator instead. This is undesirable for me so I've added the new API and tried to make property tests to ensure it stays in-sync with the equivalent behavior.How to test the change?
Test regularly, nothing should be significantly different.