From b78cdf2077c04a4bdde727267463532522d66205 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Fri, 28 Apr 2023 10:15:34 -0400 Subject: [PATCH] [demo] update JS docs (#2637) --- content/en/docs/demo/services/frontend.md | 16 +++++++++++++++- content/en/docs/demo/services/payment.md | 11 +++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/content/en/docs/demo/services/frontend.md b/content/en/docs/demo/services/frontend.md index 0fa27dd2a77c..41e94dfe700d 100644 --- a/content/en/docs/demo/services/frontend.md +++ b/content/en/docs/demo/services/frontend.md @@ -28,6 +28,10 @@ const { const { OTLPTraceExporter, } = require('@opentelemetry/exporter-trace-otlp-grpc'); +const { + OTLPMetricExporter, +} = require('@opentelemetry/exporter-metrics-otlp-grpc'); +const { PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics'); const { alibabaCloudEcsDetector, } = require('@opentelemetry/resource-detector-alibaba-cloud'); @@ -48,7 +52,17 @@ const { const sdk = new opentelemetry.NodeSDK({ traceExporter: new OTLPTraceExporter(), - instrumentations: [getNodeAutoInstrumentations()], + instrumentations: [ + getNodeAutoInstrumentations({ + // only instrument fs if it is part of another trace + '@opentelemetry/instrumentation-fs': { + requireParentSpan: true, + }, + }), + ], + metricReader: new PeriodicExportingMetricReader({ + exporter: new OTLPMetricExporter(), + }), resourceDetectors: [ containerDetector, envDetector, diff --git a/content/en/docs/demo/services/payment.md b/content/en/docs/demo/services/payment.md index fc91f3bae4c2..e8327193b2dd 100644 --- a/content/en/docs/demo/services/payment.md +++ b/content/en/docs/demo/services/payment.md @@ -55,7 +55,14 @@ const { const sdk = new opentelemetry.NodeSDK({ traceExporter: new OTLPTraceExporter(), - instrumentations: [getNodeAutoInstrumentations()], + instrumentations: [ + getNodeAutoInstrumentations({ + // only instrument fs if it is part of another trace + '@opentelemetry/instrumentation-fs': { + requireParentSpan: true, + }, + }), + ], metricReader: new PeriodicExportingMetricReader({ exporter: new OTLPMetricExporter(), }), @@ -72,7 +79,7 @@ const sdk = new opentelemetry.NodeSDK({ ], }); -sdk.start().then(() => require('./index')); +sdk.start(); ``` You can then use `opentelemetry.js` to start your app. This can be done in the