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: website_docs/getting_started/browser.md
+47-10
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,18 @@ title: "Browser"
3
3
weight: 2
4
4
---
5
5
6
-
This guide uses the example application in HTML & javascript provided below, but the steps to instrument your own application should be broadly the same. Here is an overview of what we will be doing.
6
+
This guide uses the example application in HTML & javascript provided below, but the steps to instrument your own application should be broadly the same.
7
7
8
-
- Install the required OpenTelemetry libraries
9
-
- Initialize a global [tracer](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#tracer)
10
-
- Initialize and register a [span exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-exporter)
8
+
-[Example Application](#example-application)
9
+
-[Installation](#installation)
10
+
-[Initialization and Configuration](#initialization-and-configuration)
11
+
-[Creating a Tracer Provider](#creating-a-tracer-provider)
12
+
-[Creating an Exporter](#creating-an-exporter)
13
+
-[Add Instrumentations](#add-instrumentations)
14
+
-[Meta Packages for Web](#meta-packages-for-web)
15
+
-[Instrumentation with Browser Extension](#instrumentation-with-browser-extension)
16
+
17
+
## Example Application
11
18
12
19
This is a very simple guide, if you'd like to see more complex examples go to [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/tracer-web)
13
20
@@ -38,16 +45,16 @@ Copy the following file into an empty directory and call it `index.html`.
38
45
</html>
39
46
```
40
47
41
-
## Installation
48
+
###Installation
42
49
43
50
To create traces in the browser, you will need `@opentelemetry/web`, and the instrumentation `@opentelemetry/instrumentation-document-load`:
@@ -199,3 +213,26 @@ Now, rebuild your application and open the browser again. In the console of the
199
213
]
200
214
}
201
215
```
216
+
217
+
### Add Instrumentations
218
+
219
+
If you want to instrument AJAX requests, User Interactions and others, you can register additional instrumentations for those:
220
+
221
+
```javascript
222
+
registerInstrumentations({
223
+
instrumentations: [
224
+
newUserInteractionInstrumentation(),
225
+
newXMLHttpRequestInstrumentation()
226
+
],
227
+
});
228
+
```
229
+
230
+
## Meta Packages for Web
231
+
232
+
To leverage the most common instrumentations all in one you can simply use the
233
+
[OpenTelemetry Meta Packages for Web](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-web)
234
+
235
+
## Instrumentation with Browser Extension
236
+
237
+
If you'd like to quickly preview what OpenTelemetry instrumentation would look like with your website (or any other site)
238
+
installed, you can use the [OpenTelemetry Browser Extension](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-browser-extension-autoinjection)
Copy file name to clipboardexpand all lines: website_docs/getting_started/nodejs.md
+6-8
Original file line number
Diff line number
Diff line change
@@ -72,14 +72,12 @@ These dependencies are required to configure the tracing SDK and create spans.
72
72
73
73
#### Exporter
74
74
75
-
In order to visualize and analyze your traces, you will need to export them to a tracing backend such as Jaeger. OpenTelemetry JS provides exporters for some common open source tracing backends.
75
+
In the following example, we will use the `ConsoleSpanExporter` which prints all spans to the console.
In order to visualize and analyze your traces, you will need to export them to a tracing backend.
78
+
Follow [these instructions](../exporters.md) for setting up a backend and exporter.
79
+
80
+
You may also want to use the `BatchSpanProcessor` to export spans in batches in order to more efficiently use resources.
83
81
84
82
#### Instrumentation Modules
85
83
@@ -91,7 +89,7 @@ You can also install all instrumentations maintained by the OpenTelemetry author
91
89
92
90
The tracing setup and configuration should be run before your application code. One tool commonly used for this task is the [`-r, --require module`](https://nodejs.org/api/cli.html#cli_r_require_module) flag.
93
91
94
-
Create a file with a name like `tracing.js` which will contain your tracing setup code. In this example, we will use the `ConsoleSpanExporter` which prints all spans to the console. In your application, you should use the exporter which goes with the tracing backend of your choice. You may also want to use the `BatchSpanProcessor` to export spans in batches in order to more efficiently use resources.
92
+
Create a file with a name like `tracing.js` which will contain your tracing setup code.
Copy file name to clipboardexpand all lines: website_docs/instrumentation_examples.md
+12-2
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,16 @@ weight: 4
5
5
6
6
Here are Some of the resources for Opentelemetry Instrumentation Examples
7
7
8
+
## Core Examples
9
+
10
+
The repository of the [JavaScript version of OpenTelemetry](https://github.com/svrnm/opentelemetry-js) holds some
11
+
[examples](https://github.com/svrnm/opentelemetry-js/tree/main/examples) of how to run real application with OpenTelemetry JavaScript.
12
+
13
+
## Plugin & Package Examples
14
+
15
+
Many of the packages and plugins at the [repository for OpenTelemetry JavaScript](https://github.com/open-telemetry/opentelemetry-js-contrib/)
16
+
contributions come with an usage example. You can find them in the [examples folder](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples).
0 commit comments