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
This package exposes a `NodeTracerProvider` that will automatically hook into the module loader of Node.js.
15
17
16
18
For this to work, please make sure that `NodeTracerProvider` is initialized before any other module of your application, (like `http` or `express`) is loaded.
17
19
18
20
OpenTelemetry comes with a growing number of instrumentation plugins for well know modules (see [supported modules](https://github.com/open-telemetry/opentelemetry-js#plugins)) and an API to create custom plugins (see [the plugin developer guide](https://github.com/open-telemetry/opentelemetry-js/blob/master/doc/plugin-guide.md)).
19
21
20
-
21
22
Whenever a module is loaded `NodeTracerProvider` will check if a matching instrumentation plugin has been installed.
22
23
23
24
> **Please note:** This module does *not* bundle any plugins. They need to be installed separately.
@@ -26,6 +27,7 @@ If the respective plugin was found, it will be used to patch the original module
26
27
This is done by wrapping all tracing-relevant functions.
27
28
28
29
This instrumentation code will automatically
30
+
29
31
- extract a trace-context identifier from inbound requests to allow distributed tracing (if applicable)
30
32
- make sure that this current trace-context is propagated while the transaction traverses an application (see [@opentelemetry/context-base](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-context-base/README.md) for an in-depth explanation)
31
33
- add this trace-context identifier to outbound requests to allow continuing the distributed trace on the next hop (if applicable)
@@ -34,6 +36,7 @@ This instrumentation code will automatically
34
36
In short, this means that this module will use provided plugins to automatically instrument your application to produce spans and provide end-to-end tracing by just adding a few lines of code.
35
37
36
38
## Creating custom spans on top of auto-instrumentation
39
+
37
40
Additionally to automated instrumentation, `NodeTracerProvider` exposes the same API as [@opentelemetry/tracing](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-tracing), allowing creating custom spans if needed.
// You may use a package name or absolute path to the file.
63
-
path:'@opentelemetry/plugin-http',
64
-
// http plugin options
65
-
}
66
-
}
67
-
});
64
+
constprovider=newNodeTracerProvider();
68
65
69
66
// Initialize the provider
70
67
provider.register()
@@ -74,26 +71,43 @@ provider.register()
74
71
consthttp=require('http');
75
72
```
76
73
77
-
To enable instrumentation for all [supported modules](https://github.com/open-telemetry/opentelemetry-js#plugins), create an instance of `NodeTracerProvider` without providing any plugin configuration to the constructor.
See how to automatically instrument [http](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/http) and [gRPC](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/grpc) using node-sdk.
94
106
107
+
See how to automatically instrument [http](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/http) and [gRPC](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/grpc) using node-sdk.
95
108
96
109
## Useful links
110
+
97
111
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
98
112
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
99
113
- For help or feedback on this project, join us on [gitter][gitter-url]
Copy file name to clipboardExpand all lines: packages/opentelemetry-node/test/instrumentation/node_modules/@opentelemetry/plugin-http-module/package.json
0 commit comments