Skip to content
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

src: add --title command line argument, trace event #21477

Closed
wants to merge 2 commits into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jun 22, 2018

Adds a simple utility --title command line argument to set the process title on startup. Also, emit the process_name metadata to the trace event log.

$ node --title=foo -pe "process.title"
foo

When emit trace events, the process name appears within the trace event viewer UI:

$ node --title=foo --trace-event-categories node -pe "process.title"
foo

image

Changes to process.title also appear within the trace_event log:

/cc @ofrobots @eugeneo

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 22, 2018
@jasnell
Copy link
Member Author

jasnell commented Jun 22, 2018

@jasnell
Copy link
Member Author

jasnell commented Jun 23, 2018

some relevant failures in CI.

@jasnell
Copy link
Member Author

jasnell commented Jun 23, 2018

@ofrobots ... when you get a moment, can you take a look at this? It would appear that TRACE_STR_COPY() may not be actually be copying for metadata events, but it's difficult to verify.

@jasnell jasnell added the wip Issues and PRs that are still a work in progress. label Jun 23, 2018
doc/node.1 Outdated
@@ -164,6 +164,9 @@ instead of printing to stderr.
.It Fl -throw-deprecation
Throw errors for deprecations.
.
.It Fl -title Ns = Ns Ar title
Specify the process.title on startup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing period.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove the

doc/api/cli.md Outdated
added: REPLACEME
-->

Set the `process.title` on startup.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove the

@Trott Trott added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 23, 2018
@jasnell
Copy link
Member Author

jasnell commented Jun 24, 2018

Still exploring why the trace event bit is failing on some of the CI machines.. unable to recreate locally... https://ci.nodejs.org/job/node-test-pull-request/15587/

src/node.cc Outdated
@@ -2813,6 +2817,8 @@ static void ParseArgs(int* argc,
} else if (strncmp(arg, "--security-revert=", 18) == 0) {
const char* cve = arg + 18;
Revert(cve);
} else if (strncmp(arg, "--title=", 8) == 0) {
uv_set_process_title(arg + 8);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is safe? Setting the process title (which on a lot of OS works by overwriting argv) while iterating over argv?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly not ;) still verifying and chasing down a few issues that are likely being caused by exactly this problem. I have a change staged locally that moves the actual set_process_title call to after the args are processed but haven't pushed it up to test yet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the addition of --title tied to the trace event things, or is it a convenience thing? It seems like it’s pretty easy already to set the process title from inside the JS code, so it might be okay to leave this out…?

Copy link
Member Author

@jasnell jasnell Jun 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not tied together but the use case is closely related for me. The introduction of --title is specifically for cases of profiling other users code that I don't exactly want to have to modify just to set the title... using a preload module is a bit overkill for that.

@jasnell
Copy link
Member Author

jasnell commented Jun 25, 2018

@jasnell
Copy link
Member Author

jasnell commented Jun 25, 2018

Another CI: https://ci.nodejs.org/job/node-test-pull-request/15613/

This is failing on SmartOS only at this point.

Simple utility command line argument for setting the process
title on process startup.
@jasnell
Copy link
Member Author

jasnell commented Jun 25, 2018

Ok, should be good to go now: https://ci.nodejs.org/job/node-test-pull-request/15615/

@addaleax addaleax removed the wip Issues and PRs that are still a work in progress. label Jun 25, 2018
@jasnell
Copy link
Member Author

jasnell commented Jun 25, 2018

CI is good. One unrelated flaky failure in windows.

@Trott
Copy link
Member

Trott commented Jun 26, 2018

CI is good. One unrelated flaky failure in windows.

Then it's not quite good yet. :-D

CI: https://ci.nodejs.org/job/node-test-pull-request/15625/

@jasnell
Copy link
Member Author

jasnell commented Jun 29, 2018

Let's give it one more shot since the unrelated windows failure happened again https://ci.nodejs.org/job/node-test-pull-request/15676/

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 30, 2018
jasnell added a commit that referenced this pull request Jul 11, 2018
PR-URL: #21477
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
jasnell added a commit that referenced this pull request Jul 11, 2018
Simple utility command line argument for setting the process
title on process startup.

PR-URL: #21477
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@jasnell
Copy link
Member Author

jasnell commented Jul 11, 2018

Landed in 6705356 and 9d71619

@jasnell jasnell closed this Jul 11, 2018
targos pushed a commit that referenced this pull request Jul 12, 2018
PR-URL: #21477
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Jul 12, 2018
Simple utility command line argument for setting the process
title on process startup.

PR-URL: #21477
Reviewed-By: Bradley Farias <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos added a commit that referenced this pull request Jul 17, 2018
Notable changes:

* console:
  * The `console.timeLog()` method has been implemented. (#21312)
* deps:
  * Upgrade to libuv 1.22.0. (#21731)
  * Upgrade to ICU 62.1 (Unicode 11, CLDR 33.1). (#21728)
* http:
  * Added support for passing both `timeout` and `agent` options to
    `http.request`. (#21204)
* napi:
  * Added experimental support for functions dealing with bigint numbers. (#21226)
* process:
  * The `process.hrtime.bigint()` method has been implemented. (#21256)
  * Added the `--title` command line argument to set the process title on
    startup. (#21477)
* trace_events:
  * Added process_name metadata. (#21477)
@targos targos mentioned this pull request Jul 17, 2018
targos added a commit that referenced this pull request Jul 18, 2018
Notable changes:

* console:
  * The `console.timeLog()` method has been implemented. (#21312)
* deps:
  * Upgrade to libuv 1.22.0. (#21731)
  * Upgrade to ICU 62.1 (Unicode 11, CLDR 33.1). (#21728)
* http:
  * Added support for passing both `timeout` and `agent` options to
    `http.request`. (#21204)
* napi:
  * Added experimental support for functions dealing with bigint numbers. (#21226)
* process:
  * The `process.hrtime.bigint()` method has been implemented. (#21256)
  * Added the `--title` command line argument to set the process title on
    startup. (#21477)
* trace_events:
  * Added process_name metadata. (#21477)
* Added new collaborators
  * codebytere - Shelley Vohr

PR-URL: #21851
targos added a commit that referenced this pull request Jul 18, 2018
Notable changes:

* console:
  * The `console.timeLog()` method has been implemented.
    (#21312)
* deps:
  * Upgrade to libuv 1.22.0. (#21731)
  * Upgrade to ICU 62.1 (Unicode 11, CLDR 33.1).
    (#21728)
* http:
  * Added support for passing both `timeout` and `agent` options to
    `http.request`. (#21204)
* inspector:
  * Expose the original console API in `require('inspector').console`.
    (#21659)
* napi:
  * Added experimental support for functions dealing with bigint numbers.
    (#21226)
* process:
  * The `process.hrtime.bigint()` method has been implemented.
    (#21256)
  * Added the `--title` command line argument to set the process title on
    startup. (#21477)
* trace_events:
  * Added process_name metadata.
    (#21477)
* Added new collaborators
  * codebytere - Shelley Vohr

PR-URL: #21851
targos added a commit that referenced this pull request Jul 18, 2018
Notable changes:

* console:
  * The `console.timeLog()` method has been implemented.
    (#21312)
* deps:
  * Upgrade to libuv 1.22.0. (#21731)
  * Upgrade to ICU 62.1 (Unicode 11, CLDR 33.1).
    (#21728)
* http:
  * Added support for passing both `timeout` and `agent` options to
    `http.request`. (#21204)
* inspector:
  * Expose the original console API in `require('inspector').console`.
    (#21659)
* napi:
  * Added experimental support for functions dealing with bigint numbers.
    (#21226)
* process:
  * The `process.hrtime.bigint()` method has been implemented.
    (#21256)
  * Added the `--title` command line argument to set the process title on
    startup. (#21477)
* trace_events:
  * Added process_name metadata.
    (#21477)
* Added new collaborators
  * codebytere - Shelley Vohr

PR-URL: #21851
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants