-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
PerformanceEntry toJSON() #35936
Labels
perf_hooks
Issues and PRs related to the implementation of the Performance Timing API.
Comments
@spazmodius, I agree that there is no |
targos
added
the
perf_hooks
Issues and PRs related to the implementation of the Performance Timing API.
label
Nov 5, 2020
mmomtchev
added a commit
to mmomtchev/node
that referenced
this issue
Nov 5, 2020
Render all properties of nodeTiming enumerable so JSON.stringify and Object.keys can access them Fixes: nodejs#35936
3 tasks
Yes, that's my reference point. I didn't realize the other subtypes will jsonify. |
codebytere
pushed a commit
that referenced
this issue
Nov 22, 2020
Render all properties of nodeTiming enumerable so JSON.stringify and Object.keys can access them Fixes: #35936 PR-URL: #35977 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
targos
pushed a commit
that referenced
this issue
May 1, 2021
Render all properties of nodeTiming enumerable so JSON.stringify and Object.keys can access them Fixes: #35936 PR-URL: #35977 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
My logging logs JSON for object it receives. It can use
JSON.stringify
, usually, or a custom serializer (say, forError
s). To invoke a custom serializer it needs to be able to inspect the object for some arbitrary condition (ofteninstanceof
).Unfortunately, there seems to be no way to get JSON for a
PerformaceEntry
object, and it has no reliably identifying features.Describe the solution you'd like
Support a
toJSON()
function onPerformanceEntry
, as specified.Describe alternatives you've considered
I could use a custom serializer function, if I had a way to identify the object I have in hand as a
PerformanceEntry
. Alas,obj instanceof PerformanceEntry
is impossible because that class is not exposed.I considered using
obj[util.inspect.custom]()
, which is defined onPerformanceNodeTiming
, but notPerformanceEntry
. However, again, I don't know a reliable strategy for deciding when to use it--surely not just whenever it exists.As a workaround, the client itself has to copy properties explicitly to a POJO. This is brittle and ugly, especially since object-spread is also useless. For exampe,
{ ...perf_hooks.performance.nodeTiming }
yields an empty object.The text was updated successfully, but these errors were encountered: