Skip to content

Commit 534e0d1

Browse files
svrnmjonchurchdyladan
authoredJul 28, 2021
Additional website docs updates (#2344)
Co-authored-by: Jonathan Church <me@jonchurch.com> Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
1 parent ec88344 commit 534e0d1

File tree

4 files changed

+135
-20
lines changed

4 files changed

+135
-20
lines changed
 

‎website_docs/exporters.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: "Exporters"
3+
weight: 3
4+
---
5+
6+
In order to visualize and analyze your traces, you will need to export them to a tracing backend such as Jaeger or Zipkin.
7+
OpenTelemetry JS provides exporters for some common open source tracing backends.
8+
9+
Below you will find some introductions on how to setup backends and the matching exporters.
10+
11+
## Jaeger
12+
13+
To set up Jaeger as quickly as possible, run it in a docker container:
14+
15+
```shell
16+
$ docker run -d --name jaeger \
17+
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
18+
-p 5775:5775/udp \
19+
-p 6831:6831/udp \
20+
-p 6832:6832/udp \
21+
-p 5778:5778 \
22+
-p 16686:16686 \
23+
-p 14268:14268 \
24+
-p 14250:14250 \
25+
-p 9411:9411 \
26+
jaegertracing/all-in-one:latest
27+
```
28+
29+
Install the exporter package as a dependency for your application:
30+
31+
```shell
32+
npm install --save @opentelemetry/exporter-jaeger
33+
```
34+
35+
Update your opentelemetry configuration to use the exporter and to send data to your jaeger backend:
36+
37+
```javascript
38+
const { JaegerExporter } = require("@opentelemetry/exporter-jaeger");
39+
const { BatchSpanProcessor } = require("@opentelemetry/tracing");
40+
41+
provider.addSpanProcessor(new BatchSpanProcessor(new JaegerExporter()))
42+
```
43+
44+
## Zipkin
45+
46+
To set up Zipkin as quickly as possible, run it in a docker container:
47+
48+
```shell
49+
docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin
50+
```
51+
52+
Install the exporter package as a dependency for your application:
53+
54+
```shell
55+
npm install --save @opentelemetry/exporter-zipkin
56+
```
57+
58+
Update your opentelemetry configuration to use the exporter and to send data to your zipkin backend:
59+
60+
```javascript
61+
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
62+
const { BatchSpanProcessor } = require("@opentelemetry/tracing");
63+
64+
provider.addSpanProcessor(new BatchSpanProcessor(new ZipkinExporter()))
65+
```
66+
67+
## OpenTelemetry Collector
68+
69+
If you are looking for a vendor-agnostic way to receive, process and export your
70+
telemetry data follow the instructions to setup a [OpenTelemetry collector](https://opentelemetry.io/docs/collector/)

‎website_docs/getting_started/browser.md

+47-10
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ title: "Browser"
33
weight: 2
44
---
55

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.
77

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
1118

1219
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)
1320

@@ -38,16 +45,16 @@ Copy the following file into an empty directory and call it `index.html`.
3845
</html>
3946
```
4047

41-
## Installation
48+
### Installation
4249

4350
To create traces in the browser, you will need `@opentelemetry/web`, and the instrumentation `@opentelemetry/instrumentation-document-load`:
4451

4552
```shell
4653
npm init -y
47-
npm install --save @opentelemetry/web @opentelemetry/instrumentation-document-load @opentelemetry/context-zone
54+
npm install --save @opentelemetry/api @opentelemetry/web @opentelemetry/instrumentation-document-load @opentelemetry/context-zone
4855
```
4956

50-
## Initialization and Configuration
57+
### Initialization and Configuration
5158

5259
Create a empty file called `document-load.js` and add the following code to your html right before the body end tag:
5360

@@ -57,7 +64,7 @@ Create a empty file called `document-load.js` and add the following code to your
5764

5865
We will add some code that will trace the document load timings and output those as OpenTelemetry Spans.
5966

60-
## Creating a Tracer Provider
67+
### Creating a Tracer Provider
6168

6269
Add the following code to the `document-load.js` to create a tracer provider, which brings the instrumentaion to trace document load:
6370

@@ -94,9 +101,16 @@ and open the development webserver (e.g. at `http://localhost:1234`) to see if y
94101

95102
There will be no output of traces yet, for this we need to add an exporter
96103

97-
## Creating a Console Exporter
104+
### Creating an Exporter
105+
106+
In the following example, we will use the `ConsoleSpanExporter` which prints all spans to the console.
107+
108+
In order to visualize and analyze your traces, you will need to export them to a tracing backend.
109+
Follow [these instructions](../exporters.md) for setting up a backend and exporter.
98110

99-
To export traces, modify `document-load.js` so that it matches the following code snippet:
111+
You may also want to use the `BatchSpanProcessor` to export spans in batches in order to more efficiently use resources.
112+
113+
To export traces to the console, modify `document-load.js` so that it matches the following code snippet:
100114

101115
```javascript
102116
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
@@ -199,3 +213,26 @@ Now, rebuild your application and open the browser again. In the console of the
199213
]
200214
}
201215
```
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+
new UserInteractionInstrumentation(),
225+
new XMLHttpRequestInstrumentation()
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)

‎website_docs/getting_started/nodejs.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,12 @@ These dependencies are required to configure the tracing SDK and create spans.
7272

7373
#### Exporter
7474

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.
7676

77-
- Jaeger - `@opentelemetry/exporter-jaeger`
78-
- Zipkin - `@opentelemetry/exporter-zipkin`
79-
- OpenTelemetry Protocol
80-
- GRPC - `@opentelemetry/exporter-collector-grpc`
81-
- Protobuf/HTTP - `@opentelemetry/exporter-collector-proto`
82-
- JSON/HTTP - `@opentelemetry/exporter-collector`
77+
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.
8381

8482
#### Instrumentation Modules
8583

@@ -91,7 +89,7 @@ You can also install all instrumentations maintained by the OpenTelemetry author
9189

9290
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.
9391

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.
9593

9694
```javascript
9795
/* tracing.js */

‎website_docs/instrumentation_examples.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ weight: 4
55

66
Here are Some of the resources for Opentelemetry Instrumentation Examples
77

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).
17+
818
## Community Resources
919

1020
### nodejs-opentelemetry-tempo
@@ -13,6 +23,6 @@ Project demonstrating Complete Observability Stack utilizing [Prometheus](https:
1323

1424
Checkout [nodejs-opentelemetry-tempo](https://github.com/mnadeem/nodejs-opentelemetry-tempo) and get started
1525

16-
````bash
26+
```bash
1727
docker-compose up --build
18-
````
28+
```

0 commit comments

Comments
 (0)
Please sign in to comment.