Skip to content

src: internalize v8::ConvertableToTraceFormat in traces #57866

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Apr 13, 2025

v8::ConvertableToTraceFormat is only available in legacy V8 tracing
API and no longer supported in perfetto. This internalize
node::tracing::TracedValue and v8::ConvertableToTraceFormat by
defining specialized trace argument classes.

Using the new format in traces be like:

MyArgs traced_value(...);
TRACE_EVENT1("my_category", "event_name", "my_args", CastTracedValue(traced_value));

The newly defined structured trace argument classes can be easily
converted to perfetto::TracedValue by perfetto traced value protocol.
For example, when adding perfetto support, CastTracedValue will be a
no-op and these classes can add a new conversion method like:

class Foo {
  void WriteIntoTrace(TracedValue context) const {
    auto dict = std::move(context).WriteDictionary();
    dict->Add("key", 42);
    dict->Add("foo", "bar");
    dict->Add("member", member_);
  }
};

Refs: nodejs/diagnostics#654
Refs: https://github.com/google/perfetto/blob/9ddf987d48cdfd9129987a3af1e85052c377756f/include/perfetto/tracing/traced_value.h#L46

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Apr 13, 2025
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 13, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 13, 2025
@nodejs-github-bot

This comment was marked as outdated.

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas force-pushed the perfetto/traced-value branch from f5c59b2 to 1a1951f Compare April 22, 2025 11:04
@legendecas
Copy link
Member Author

I can not reproduce the windows test failure locally. Trying to rebase on top of the main branch and trigger a CI run again.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2025
@nodejs-github-bot
Copy link
Collaborator

`v8::ConvertableToTraceFormat` is only available in legacy V8 tracing
API and no longer supported in perfetto. This internalize
`node::tracing::TracedValue` and `v8::ConvertableToTraceFormat` by
defining specialized trace argument classes.

The newly defined structured trace argument classes can be easily
converted to `perfetto::TracedValue` by perfetto traced value protocol.
For example, when adding perfetto support, `CastTracedValue` will be a
no-op and these classes can add a new conversion method like:

```cpp
class Foo {
  void WriteIntoTrace(TracedValue context) const {
    auto dict = std::move(context).WriteDictionary();
    dict->Add("key", 42);
    dict->Add("foo", "bar");
    dict->Add("member", member_);
  }
};
```
@legendecas legendecas force-pushed the perfetto/traced-value branch from 1a1951f to 596fd86 Compare April 23, 2025 09:15
@legendecas
Copy link
Member Author

Rebased with #57987 to fix linter errors.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants