1 | # OpenTelemetry Core
|
2 |
|
3 | [![NPM Published Version][npm-img]][npm-url]
|
4 | [![Apache License][license-image]][license-image]
|
5 |
|
6 | This package provides default implementations of the OpenTelemetry API for trace and metrics. It's intended for use both on the server and in the browser.
|
7 |
|
8 | ## Built-in Implementations
|
9 |
|
10 | - [OpenTelemetry Core](#opentelemetry-core)
|
11 | - [Built-in Implementations](#built-in-implementations)
|
12 | - [Built-in Propagators](#built-in-propagators)
|
13 | - [W3CTraceContextPropagator Propagator](#w3ctracecontextpropagator-propagator)
|
14 | - [Composite Propagator](#composite-propagator)
|
15 | - [Baggage Propagator](#baggage-propagator)
|
16 | - [Useful links](#useful-links)
|
17 | - [License](#license)
|
18 |
|
19 | ### Built-in Propagators
|
20 |
|
21 | #### W3CTraceContextPropagator Propagator
|
22 |
|
23 | OpenTelemetry provides a text-based approach to propagate context to remote services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/) HTTP headers.
|
24 |
|
25 | ```js
|
26 | const api = require("@opentelemetry/api");
|
27 | const { W3CTraceContextPropagator } = require("@opentelemetry/core");
|
28 |
|
29 | /* Set Global Propagator */
|
30 | api.propagation.setGlobalPropagator(new W3CTraceContextPropagator());
|
31 | ```
|
32 |
|
33 | #### Composite Propagator
|
34 |
|
35 | Combines multiple propagators into a single propagator.
|
36 |
|
37 | > This is used as a default Propagator
|
38 |
|
39 | ```js
|
40 | const api = require("@opentelemetry/api");
|
41 | const { CompositePropagator } = require("@opentelemetry/core");
|
42 |
|
43 | /* Set Global Propagator */
|
44 | api.propagation.setGlobalPropagator(new CompositePropagator());
|
45 | ```
|
46 |
|
47 | #### Baggage Propagator
|
48 |
|
49 | Provides a text-based approach to propagate [baggage](https://w3c.github.io/baggage/) to remote services using the [OpenTelemetry Baggage Propagation](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/baggage/api.md#baggage-propagation) HTTP headers.
|
50 |
|
51 | ```js
|
52 | const api = require("@opentelemetry/api");
|
53 | const { W3CBaggagePropagator } = require("@opentelemetry/core");
|
54 |
|
55 | /* Set Global Propagator */
|
56 | api.propagation.setGlobalPropagator(new W3CBaggagePropagator());
|
57 | ```
|
58 |
|
59 | ## Useful links
|
60 |
|
61 | - For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
62 | - For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
|
63 | - For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
|
64 |
|
65 | ## License
|
66 |
|
67 | Apache 2.0 - See [LICENSE][license-url] for more information.
|
68 |
|
69 | [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
70 | [license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
|
71 | [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
72 | [npm-url]: https://www.npmjs.com/package/@opentelemetry/core
|
73 | [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fcore.svg
|