[ja] fix: drifted files of content/ja/docs/languages/js/ #7904
+348
−290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
original
preview.
drifted diffs.
{{% /tab %}} {{% tab JavaScript %}}
@@ -55,12 +50,13 @@ npm install undici \
{{% /tab %}} {{< /tabpane >}}
-Next, create a new file called
client.ts
(or client.js) with the following+Next, create a new file called
client.ts
(orclient.js
) with the followingcontent:
{{< tabpane text=true >}} {{% tab TypeScript %}}
{{% /tab %}} {{% tab JavaScript %}}
@@ -132,7 +127,7 @@ Start a second shell and run the
client.ts
(orclient.js
):{{< tabpane text=true >}} {{% tab TypeScript %}}
{{% /tab %}} {{% tab JavaScript %}}
@@ -154,7 +149,7 @@ similar to the following:
}
},
traceId: 'cccd19c3a2d10e589f01bfe2dc896dc2',
traceState: undefined,
name: 'GET',
id: '6f64ce484217a7bf',
@@ -174,14 +169,19 @@ similar to the following:
Take note of the traceId (
cccd19c3a2d10e589f01bfe2dc896dc2
) and ID(
6f64ce484217a7bf
). Both can be found in the output of client as well:-
javascript {hl_lines=["6-7"]} +
javascript {hl_lines=[6,9]}{
resource: {
attributes: {
// ...
},
traceId: 'cccd19c3a2d10e589f01bfe2dc896dc2',
traceState: undefined,
name: 'GET /rolldice',
id: '027c5c8b916d29da',
@@ -469,12 +469,12 @@ To enable OpenTelemetry and see the context propagation in action, create an
additional file called
instrumentation.js
with the following content:and
After the client has sent data to the server and terminated you should see spans
diff --git a/content/en/docs/languages/js/getting-started/nodejs.md b/content/en/docs/languages/js/getting-started/nodejs.md
index c16fb07c..ffe188ac 100644
--- a/content/en/docs/languages/js/getting-started/nodejs.md
+++ b/content/en/docs/languages/js/getting-started/nodejs.md
@@ -3,7 +3,7 @@ title: Node.js
description: Get telemetry for your app in less than 5 minutes!
aliases: [/docs/js/getting_started/nodejs]
weight: 10
-cSpell:ignore: autoinstrumentations KHTML rolldice
+cSpell:ignore: autoinstrumentations rolldice
This page will show you how to get started with OpenTelemetry in Node.js.
@@ -47,14 +47,8 @@ Next, install Express dependencies.
{{< tabpane text=true >}} {{% tab TypeScript %}}
-npm install typescript \ - ts-node \ - @types/node \ - express \ - @types/express - -# initialize typescript -npx tsc --init +npm install express @types/express +npm install -D tsx # a tool to run TypeScript (.ts) files directly with node
{{% /tab %}} {{% tab JavaScript %}}
@@ -122,7 +116,7 @@ Run the application with the following command and open
{{< tabpane text=true >}} {{% tab TypeScript %}}
@@ -167,10 +161,14 @@ To find all autoinstrumentation modules, you can look at the
The instrumentation setup and configuration must be run before your
application code. One tool commonly used for this task is the
---require flag.
+--import flag.
-Create a file named
instrumentation.ts
(orinstrumentation.js
if not using-TypeScript) , which will contain your instrumentation setup code.
+Create a file named
instrumentation.ts
(orinstrumentation.mjs
if not using+TypeScript), which will contain your instrumentation setup code.
+
+{{% alert title="Note" %}} The following examples using
+
--import instrumentation.ts
(TypeScript) require Node.js v.20 or later. If you+are using Node.js v.18, please use the JavaScript example. {{% /alert %}}
{{< tabpane text=true >}} {{% tab TypeScript %}}
@@ -198,17 +196,14 @@ sdk.start();
{{% /tab %}} {{% tab JavaScript %}}
{{% /tab %}} {{% tab JavaScript %}}
@@ -254,82 +249,98 @@ few times. After a while you should see the spans printed in the console by the
View example output
-
json +
js{
},
-}
-{
},
-}
-{
},
}
{
},
}
{{% /tab %}} {{% tab JavaScript %}}
@@ -115,7 +112,7 @@ add the following code to it:
@@ -244,18 +241,18 @@ sdk.start();
{{% /tab %}} {{% tab JavaScript %}}
{{% /tab %}} {{% tab JavaScript %}}
{{% /tab %}} {{< /tabpane >}}
@@ -499,7 +498,7 @@ First, in the application file
app.ts
(orapp.js
):{{% /tab %}} {{% tab JavaScript %}}
{{% /tab %}} {{< /tabpane >}}
@@ -686,19 +685,28 @@ node --require ./instrumentation.js app.js
After a while, you should see the spans printed in the console by the
ConsoleSpanExporter
, something like this:-
json +
js{
}
@@ -799,7 +816,7 @@ The previous examples showed how to create an active span. In some cases, you'll
want to create inactive spans that are siblings of one another rather than being
nested.
-
javascript +
jsconst doWork = () => {
const span1 = tracer.startSpan('work-1');
// do some work
@@ -949,8 +966,8 @@ Add the following to the top of your application file:
@@ -958,8 +975,8 @@ import {
@@ -970,8 +987,8 @@ Finally, you can update your file to include semantic attributes:
{{% /tab %}} {{% tab JavaScript %}}
{{% /tab %}} {{< /tabpane >}}
@@ -1437,7 +1454,7 @@ First, in the application file
app.ts
(orapp.js
):