Skip to content

Commit

Permalink
chore(gatsby): add environment variable for setting tracing config fi…
Browse files Browse the repository at this point in the history
…le (#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>
  • Loading branch information
3 people authored Sep 11, 2021
1 parent 425b8f5 commit 323920d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit 323920d

Please sign in to comment.