This guide is for instrumenting Gatsby builds and sending that data as Traces
to New Relic. It uses the in-built Jaeger
configuration in Gatsby, along with the New Relic OTLP Native Ingest container.
See the Internal guide for additional details - https://docs-preview.newrelic.com/docs/otlp-native-ingest/
-
Generate an api-key insert
-
Set as Environment Variable in Terminal:
export NEW_RELIC_INSERT_KEY=<INSERT_KEY>
-
To set this permanently on your Mac in Terminal:
nano .bash_profile
- Paste in
export NEW_RELIC_INSERT_KEY=<INSERT_KEY>
at the bottom CTRL+O
thenENTER
to saveCTRL+X
to go back to terminal
The docs site already has the files and commands setup for this in src/telemetry.
- Start the Opentelemetry Container:
yarn otel
- Running either of these will load the
jaeger
config:yarn develop
yarn build:develop
Create a file called otel-config.yaml
, preferably in your working directory, with the following:
extensions:
health_check:
receivers:
jaeger:
protocols:
thrift_http:
endpoint: "0.0.0.0:14268"
processors:
batch:
timeout: 1s
exporters:
otlp:
endpoint: otlp.nr-data.net:4317
headers:
api-key: ${NEW_RELIC_INSERT_KEY}
service:
pipelines:
traces:
receivers: [jaeger]
processors: [batch]
exporters: [otlp]
extensions: [health_check]
If you are using a Staging Account, change the endpoint to staging.otlp.nr-data.net:4317
- Make sure Docker Daemon is running and run in terminal:
docker run --rm -e NEW_RELIC_INSERT_KEY -p 13133:13133 -p 8888:8888 -p 6831:6831 -p 14268:14268 -p 55680-55681:55680-55681 -v "${PWD}/otel-config.yaml":/otel-config.yaml --name otelcol otel/opentelemetry-collector --config otel-config.yaml
-
Install the jaeger client in your project:
yarn add jaeger-client
-
Config
- The
jaeger-local.js
is located in./node_modules/gatsby/dist/utils/tracer/
- serviceName - The Entity it reports under in NR
- Tags - Add your own depending on your needs for filtering
- These will appear as Attribute in the Distributed Tracing UI
- The
You have to add the tracing flag to the build command, this should work with any gatsby related command:
yarn build:production --open-tracing-config-file node_modules/gatsby/dist/utils/tracer/jaeger-local.js