Skip to content

Commit 5be5217

Browse files
thgaoobecny
andauthored
feat: Add React Plugin (open-telemetry#164)
* feat(opentelemetry-plugin-react-load): instruments mounting * test(opentelemetry-plugin-react-load): added tests for mounting spans * refactor(opentelemetry-plugin-react-load): cleaned up types * feat(opentelemetry-plugin-react-load): added attributes * feat(opentelemetry-plugin-react-load): updating flow spans + tests * fix(opentelemetry-plugin-react-load): root of codecov test command fix * fix(opentelemetry-plugin-react-load): make attr names snake case * fix(opentelemetry-plugin-react-load): removed logs from test components * feat(opentelemetry-plugin-react-load): unmounting instrument * feat(opentelemetry-plugin-react-load): base func for error handling * refactor(opentelemetry-plugin-react-load): working component approach - changed plugin model to component based approach - fixed tests * fix(opentelemetry-plugin-react-load): fixed js docs * fix(opentelemetry-plugin-react-load): fixed error span naming and bug * fix(opentelemetry-plugin-react-load): use version * style(opentelemetry-plugin-react-load): cleaned up typos * style(opentelemetry-plugin-react-load): set up eslint + ran linter * test(opentelemetry-plugin-react-load): unmounting test * style(opentelemetry-plugin-react-load): ran linter * fix(opentelemetry-plugin-react-load): jsonified state stringify error * docs(opentelemetry-plugin-react-load): react plugin docs & example * fix(opentelemetry-plugin-react-load): make logs warn & fix react depend * docs(opentelemetry-plugin-react-load): preact example * style(opentelemetry-plugin-react-load): eof newlines * fix: Update examples/react-load/react/README.md Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com> * fix: context propagation for other plugins * fix: removed unsed version variable * style: redundant variable initializer * refactor: name parent spans when starting span * style: clean up react load examples/docs * docs: added docker to react load examples Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com>
1 parent d4faad2 commit 5be5217

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2742
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ OpenTelemetry can collect tracing data automatically using plugins. Vendors/User
6969
- [@opentelemetry/plugin-document-load][otel-plugin-document-load]
7070
- [@opentelemetry/plugin-xml-http-request][otel-plugin-xml-http-request]
7171
- [@opentelemetry/plugin-user-interaction][otel-plugin-user-interaction]
72+
- [@opentelemetry/plugin-react-load][otel-plugin-react-load]
7273

7374
## Contributing
7475

@@ -92,6 +93,7 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
9293
[otel-plugin-https]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-https
9394
[otel-plugin-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-dns
9495
[otel-plugin-document-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-plugin-document-load
96+
[otel-plugin-react-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-plugin-react-load
9597
[otel-plugin-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-ioredis
9698
[otel-plugin-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-mongodb
9799
[otel-plugin-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-mysql
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"env": {
3+
"test": {
4+
"presets": [
5+
["preact-cli/babel", { "modules": "commonjs" }]
6+
]
7+
}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
size-plugin.json
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Overview
2+
3+
The React Load plugin provides auto-instrumentation for react lifecycle methods.
4+
This example uses the plugin and exports them to the console.
5+
6+
The example will show traces belong to the mounting, updating, and umounting flows as defined by React 16.4+. In this example we can show how this plugin can also be used in a Preact app.
7+
8+
# Installation
9+
```
10+
# from this directory
11+
npm install
12+
```
13+
14+
# Run the example
15+
Run docker
16+
```
17+
# from this directory
18+
npm run docker:start
19+
```
20+
21+
Run app
22+
```
23+
# from this directory
24+
npm run build
25+
npm start
26+
```
27+
28+
By default, the application runs on port 8080.
29+
30+
Open Zipkin page at http://localhost:9411/zipkin/ - you should be able to see the spans in zipkin
31+
32+
## Screenshots of traces
33+
Take note of the parent-child relationships.
34+
### First load
35+
Upon loading, http://localhost:8080 mounting spans will be exported
36+
<p align="center"><img src="./images/mounting.png?raw=true"/></p>
37+
<p align="center"><img src="./images/zipkin-mounting.png?raw=true"/></p>
38+
39+
### Pressing 'Enter'
40+
Here we can see the previous component unmounting and the new component mounting.
41+
<p align="center"><img src="./images/redirect.png?raw=true"/></p>
42+
<p align="center"><img src="./images/zipkin-redirect.png?raw=true"/></p>
43+
<p align="center"><img src="./images/zipkin-redirect2.png?raw=true"/></p>
44+
45+
### Pressing 'Make Request'
46+
While in loading state:
47+
<p align="center"><img src="./images/updating.png?raw=true"/></p>
48+
<p align="center"><img src="./images/zipkin-updating.png?raw=true"/></p>
49+
50+
After a few seconds (when the request is fulfilled):
51+
<p align="center"><img src="./images/updating2.png?raw=true"/></p>
52+
<p align="center"><img src="./images/zipkin-updating2.png?raw=true"/></p>
53+
54+
55+
# Useful links
56+
- For more information on OpenTelemetry, visit: [opentelemetry.io][otel]
57+
- For more information on OpenTelemetry for Node.js, visit: [@opentelemetry/node][otel-node]
58+
59+
# LICENSE
60+
61+
Apache 2.0 - See [LICENSE][license-url] for more information.
62+
63+
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE
64+
[otel]: https://opentelemetry.io/
65+
[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
receivers:
2+
otlp:
3+
endpoint: 0.0.0.0:55678
4+
5+
exporters:
6+
zipkin:
7+
url: "http://zipkin-all-in-one:9411/api/v2/spans"
8+
9+
processors:
10+
batch:
11+
queued_retry:
12+
13+
service:
14+
pipelines:
15+
traces:
16+
receivers: [otlp]
17+
exporters: [zipkin]
18+
processors: [batch, queued_retry]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "2"
2+
services:
3+
4+
# Collector
5+
collector:
6+
image: omnition/opentelemetry-collector-contrib:0.2.8
7+
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
8+
volumes:
9+
- ./collector-config.yaml:/conf/collector-config.yaml
10+
ports:
11+
- "55678:55678"
12+
depends_on:
13+
- zipkin-all-in-one
14+
15+
# Zipkin
16+
zipkin-all-in-one:
17+
image: openzipkin/zipkin:latest
18+
ports:
19+
- "9411:9411"
212 KB
Loading
347 KB
Loading
431 KB
Loading
424 KB
Loading

0 commit comments

Comments
 (0)