You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ use the latest and greatest features, and best practices.
17
17
|[grpc](grpc/)| gRPC Instrumentation to automatically collect trace data and export them to the backend of choice | Intermediate |
18
18
|[otlp-exporter-node](otlp-exporter-node/)| This example shows how to use `@opentelemetry/exporter-otlp-http` to instrument a simple Node.js application | Intermediate |
19
19
|[opentracing-shim](opentracing-shim/)| This is a simple example that demonstrates how existing OpenTracing instrumentation can be integrated with OpenTelemetry | Intermediate |
20
+
|[esm-http-ts](esm-http-ts/)| This is a simple example that demonstrates tracing HTTP request, with an app written in TypeScript and transpiled to ES Modules. | Intermediate |
20
21
21
22
Examples of experimental packages can be found at [experimental/examples](../experimental/examples).
This is a simple example that demonstrates tracing HTTP request, with an app written in TypeScript and transpiled to ES Modules.
4
+
5
+
## Installation
6
+
7
+
```sh
8
+
# from this directory
9
+
npm install
10
+
npm run build
11
+
npm start
12
+
```
13
+
14
+
In a separate terminal, `curl localhost:3000`.
15
+
16
+
See two spans in the console (one manual, one for http instrumentation)
17
+
18
+
## Useful links
19
+
20
+
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
21
+
- For more information on OpenTelemetry for Node.js, visit: <https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node>
"outDir": "build"/* Specify an output folder for all emitted files. */,
14
+
15
+
/* Interop Constraints */
16
+
"allowSyntheticDefaultImports": true/* Allow 'import x from y' when a module doesn't have a default export. */,
17
+
"esModuleInterop": true/* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
18
+
"forceConsistentCasingInFileNames": true/* Ensure that casing is correct in imports. */,
19
+
20
+
/* Completeness */
21
+
"skipLibCheck": true/* Skip type checking all .d.ts files. */
Copy file name to clipboardExpand all lines: experimental/packages/opentelemetry-instrumentation/README.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,12 +219,18 @@ If nothing is specified the global registered provider is used. Usually this is
219
219
There might be usecase where someone has the need for more providers within an application. Please note that special care must be takes in such setups
220
220
to avoid leaking information from one provider to the other because there are a lot places where e.g. the global `ContextManager` or `Propagator` is used.
221
221
222
+
## Instrumentation for ES Modules In NodeJS (experimental)
223
+
224
+
As the module loading mechanism for ESM is different than CJS, you need to select a custom loader so instrumentation can load hook on the esm module it want to patch. To do so, you must provide the `--experimental-loader=@opentelemetry/instrumentation/hook.mjs` flag to the `node` binary. Alternatively you can set the `NODE_OPTIONS` environment variable to `NODE_OPTIONS="--experimental-loader=@opentelemetry/instrumentation/hook.mjs"`.
225
+
As the ESM module loader from NodeJS is experimental, so is our support for it. Feel free to provide feedback or report issues about it.
226
+
227
+
**Note**: ESM Instrumentation is not yet supported for Node 20.
228
+
222
229
## Limitations
223
230
224
-
Instrumentations for external modules (e.g. express, mongodb,...) hooks the `require` call. Therefore following conditions need to be met that this mechanism can work:
231
+
Instrumentations for external modules (e.g. express, mongodb,...) hooks the `require` call or `import` statement. Therefore following conditions need to be met that this mechanism can work:
225
232
226
-
*`require` is used. ECMA script modules (using `import`) is not supported as of now
227
-
* Instrumentations are registered **before** the module to instrument is `require`ed
233
+
* Instrumentations are registered **before** the module to instrument is `require`ed (CJS only)
228
234
* modules are not included in a bundle. Tools like `esbuild`, `webpack`, ... usually have some mechanism to exclude specific modules from bundling
0 commit comments