-
Notifications
You must be signed in to change notification settings - Fork 53
[RUM-10500] [V3] Attributes encoding and validation #1008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RUM-10500] [V3] Attributes encoding and validation #1008
Conversation
68036d3 to
a4725c4
Compare
packages/core/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts
Show resolved
Hide resolved
sbarrio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments. Good work!
|
Thanks @sbarrio 🙌 I have addressed your comments in a new commit. I still have to do some further manual testing before merging this. After I am done, I will squash the commits and merge this in v3 :) |
|
@sbarrio I made some changes to introduce the 128 attributes limit + additional testing for this new logic and for making sure encoding does not modify the original objects |
|
LGTM! Just a heads up, due to the rename from DdSDK -> NativeDdSdk you will need to adapt all calls to the attributes API. These are the methods that will need adapting: Attributes API Please let me know if you want me to handle the merge or if you have any questions with it 🙂 |
fccaf0d to
513aad5
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: c1145b2 | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
7f280ea to
751dcb1
Compare
751dcb1 to
c1145b2
Compare
What does this PR do?
Starting from v3, we are changing the way attributes are handled to improve safety, consistency and compatibility with native SDKs, and to support more attribute types.
What’s New
Date,Error, andMapare properly serializeda.b.c = value), matching the format expected by native SDKs and avoiding ambiguous outcomes.contextkey to maintain schema consistency.Motivation
In React Native, it’s common for developers to pass complex objects as attributes (e.g. partial or full Redux/Zustand state, raw
Errorobjects). These may contain unserializable values that would break serialization. While ideally users should only pass clean dictionaries of encodable values, in practice they expect the SDK to handle arbitrary objects to some extent.This change ensures:
Example Transformations
"foo"→{ context: "foo" }{ user: { profile: { name: "Alice" } } }→{ "user.profile.name": "Alice" }new Error("Boom")→{ "context.name": "Error", "context.message": "Boom", "context.stack": "...", ... }new Map([["k1", 1], ["k2", "v2"]])→{ "context": [ { "key": "k1", "keyType": "string", "value": 1 }, { "key": "k2", "keyType": "string", "value": "v2" } ] }Unsupported values like
Symbol("x")or() => {}→{}(dropped with warning)Benchmarks