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 provides everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.
9
9
10
-
## Basic Use
10
+
## Quick Start
11
11
12
-
### API Entry Point
12
+
To get started tracing you need to install the SDK and plugins, create a TracerProvider, and register it with the API.
13
13
14
-
API entry points are defined as global singleton objects `trace` and `metrics` which contain methods used to initialize SDK implementations and acquire resources from the API.
14
+
### Install Dependencies
15
+
16
+
```sh
17
+
$ # Install tracing dependencies
18
+
$ npm install \
19
+
@opentelemetry/core \
20
+
@opentelemetry/node \
21
+
@opentelemetry/tracing \
22
+
@opentelemetry/exporter-jaeger \ # add exporters as needed
23
+
@opentelemetry/plugin-http # add plugins as needed
24
+
25
+
$ # Install metrics dependencies
26
+
$ npm install \
27
+
@opentelemetry/metrics \
28
+
@opentelemetry/exporter-prometheus # add exporters as needed
29
+
```
30
+
31
+
### Initialize the SDK
32
+
33
+
Before any other module in your application is loaded, you must initialize the global tracer and meter providers. If you fail to initialize a provider, no-op implementations will be provided to any library which acquires them from the API.
34
+
35
+
To collect traces and metrics, you will have to tell the SDK where to export telemetry data to. This example uses Jaeger and Prometheus, but exporters exist for [other tracing backends][other-tracing-backends]. If you're not sure if there is an exporter for your tracing backend, contact your tracing provider.
If you prefer to choose your own propagator or context manager, you may pass an options object into the `tracerProvider.register()` method. Omitted or `undefined` options will be replaced by a default value and `null` values will be skipped.
If you are writing an instrumentation library, or prefer to call the API methods directly rather than using the `register` method on the Tracer/Meter Provider, OpenTelemetry provides direct access to the underlying API methods through the `@opentelemetry/api` package. API entry points are defined as global singleton objects `trace`, `metrics`, `propagation`, and `context` which contain methods used to initialize SDK implementations and acquire resources from the API.
15
114
16
115
-[Trace API Documentation][trace-api-docs]
17
116
-[Metrics API Documentation][metrics-api-docs]
117
+
-[Propagation API Documentation][propagation-api-docs]
/* returns a meter from the registered global meter provider (no-op if a working provider has not been initialized); */
34
135
api.metrics.getMeter(name, version);
35
-
```
36
-
37
-
### Application Owners
38
-
39
-
Application owners will also need a working OpenTelemetry SDK implementation. OpenTelemetry provides working SDK implementations for [web] and [node] for both [tracing] and [metrics].
40
-
41
-
#### Simple NodeJS Example
42
136
43
-
Before any other module in your application is loaded, you must initialize the global tracer and meter registries. If you fail to initialize a provider, no-op implementations will be provided to any library which acquires them from the API.
0 commit comments