diff --git a/docs/docs/performance-tracing.md b/docs/docs/performance-tracing.md index 9e877647a0ffc..9359d8d959847 100644 --- a/docs/docs/performance-tracing.md +++ b/docs/docs/performance-tracing.md @@ -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 @@ -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 diff --git a/packages/gatsby/src/commands/build.ts b/packages/gatsby/src/commands/build.ts index 93e7c6dfd779e..6b1b654e61807 100644 --- a/packages/gatsby/src/commands/build.ts +++ b/packages/gatsby/src/commands/build.ts @@ -75,7 +75,9 @@ module.exports = async function build(program: IBuildArgs): Promise { 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() diff --git a/packages/gatsby/src/commands/develop-process.ts b/packages/gatsby/src/commands/develop-process.ts index 95758861a973c..87e2823110039 100644 --- a/packages/gatsby/src/commands/develop-process.ts +++ b/packages/gatsby/src/commands/develop-process.ts @@ -101,7 +101,9 @@ module.exports = async (program: IDevelopArgs): Promise => { 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`)