Skip to content

Commit 323920d

Browse files
rudouglasgatsbybotKyleAMathews
authored
chore(gatsby): add environment variable for setting tracing config file (#32513)
* chore: add option for openTracingConfigFile env * chore: format * Standardize env variable name + document Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
1 parent 425b8f5 commit 323920d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

docs/docs/performance-tracing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The configuration file is a JavaScript file that exports two functions: `create`
3333

3434
### 3. Start Gatsby with tracing turned on
3535

36-
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.
36+
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.
3737

3838
## Tracing backend examples
3939

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

110110
```shell
111-
node -r ./tracing.js node_modules/gatsby/cli.js build --open-tracing-config-file tracing.js
111+
GATSBY_OPEN_TRACING_CONFIG_FILE=tracing.js node -r ./tracing.js node_modules/gatsby/cli.js build
112112
```
113113

114114
### Local Jaeger with Docker

packages/gatsby/src/commands/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
7575
markWebpackStatusAsPending()
7676

7777
const publicDir = path.join(program.directory, `public`)
78-
initTracer(program.openTracingConfigFile)
78+
initTracer(
79+
process.env.GATSBY_OPEN_TRACING_CONFIG_FILE || program.openTracingConfigFile
80+
)
7981
const buildActivity = report.phantomActivity(`build`)
8082
buildActivity.start()
8183

packages/gatsby/src/commands/develop-process.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ module.exports = async (program: IDevelopArgs): Promise<void> => {
101101
process.exit(0)
102102
})
103103

104-
initTracer(program.openTracingConfigFile)
104+
initTracer(
105+
process.env.GATSBY_OPEN_TRACING_CONFIG_FILE || program.openTracingConfigFile
106+
)
105107
markWebpackStatusAsPending()
106108
reporter.pendingActivity({ id: `webpack-develop` })
107109
telemetry.trackCli(`DEVELOP_START`)

0 commit comments

Comments
 (0)