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
Add logs mapper #374
Add logs mapper #374
Conversation
e710ca4
to
0df95e8
Compare
cccbc04
to
3f0edc8
Compare
7e896cc
to
b9ed21c
Compare
b9ed21c
to
c4ab3b9
Compare
InternalLog.log( | ||
`Setting attributes ${JSON.stringify(attributes)}`, | ||
SdkVerbosity.DEBUG | ||
); | ||
return DdSdk.setAttributes(attributes); | ||
await DdSdk.setAttributes(attributes); | ||
AttributesSingleton.getInstance().setAttributes(attributes); |
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.
There's no return statement anymore, is this normal?
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.
Yes it is intended.
We used to return DdSdk.setAttributes(attributes)
which itself returns a Promise<void>
(promise resolving a value equal to undefined
).
Now that we turned the function into an async
one, and used await
, it also returns a Promise
, which in this case is a Promise<void>
as we don't return anything.
This would be equivalent to return;
or return undefined
but the more common syntax is to not use a return statement.
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.
So using async makes an implicit return Promise, I guess this is knowledge I missed. 😅
What does this PR do?
Add logs event mapper.
If the event mapper returns
null
, it is dropped.Additional Notes
We only allow for modification of
context
andmessage
for now.We can add support for
attributes
anduser.extraInfo
later, but I don't see much usage of this, so let's wait and see if there is a lot of request before adding this.Review checklist (to be filled by reviewers)