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

chore(gatsby): add environment variable for setting tracing config file #32513

Merged
merged 5 commits into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/performance-tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The configuration file is a JavaScript file that exports two functions: `create`

### 3. Start Gatsby with tracing turned on

The above configuration file can be passed to Gatsby with the `--open-tracing-config-file` command-line option. When Gatsby is started with this option, it will load the supplied tracing configuration file, and call its `create` function. The returned Tracer will be used for tracing the build. Once the build has stopped, the configuration file's `stop` method will be called, allowing the tracing implementation to perform any cleanup.
The above configuration file can be passed to Gatsby with the `--open-tracing-config-file` command-line option or an environment variable named `GATSBY_OPEN_TRACING_CONFIG_FILE`. When Gatsby is started with this option, it will load the supplied tracing configuration file, and call its `create` function. The returned Tracer will be used for tracing the build. Once the build has stopped, the configuration file's `stop` method will be called, allowing the tracing implementation to perform any cleanup.

## Tracing backend examples

Expand Down Expand Up @@ -108,7 +108,7 @@ exports.stop = async () => {
we run Gatsby in a special way telling Node to require our tracing file immediately.

```shell
node -r ./tracing.js node_modules/gatsby/cli.js build --open-tracing-config-file tracing.js
GATSBY_OPEN_TRACING_CONFIG_FILE=tracing.js node -r ./tracing.js node_modules/gatsby/cli.js build
```

### Local Jaeger with Docker
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
markWebpackStatusAsPending()

const publicDir = path.join(program.directory, `public`)
initTracer(program.openTracingConfigFile)
initTracer(
process.env.GATSBY_OPEN_TRACING_CONFIG_FILE || program.openTracingConfigFile
)
const buildActivity = report.phantomActivity(`build`)
buildActivity.start()

Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby/src/commands/develop-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ module.exports = async (program: IDevelopArgs): Promise<void> => {
process.exit(0)
})

initTracer(program.openTracingConfigFile)
initTracer(
process.env.GATSBY_OPEN_TRACING_CONFIG_FILE || program.openTracingConfigFile
)
markWebpackStatusAsPending()
reporter.pendingActivity({ id: `webpack-develop` })
telemetry.trackCli(`DEVELOP_START`)
Expand Down