Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 34b5bc1

Browse files
crdgonzalezcadraffensperger
authored andcommitted
Refactor packages and rename @opencensus/web-all to @opencensus/web-scripts (#148)
1 parent f508a3a commit 34b5bc1

Some content is hidden

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

50 files changed

+13764
-58499
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased
66

7+
- Rename `@opencensus/web-all` to `@opencensus/web-scripts` so now this package
8+
is only in charge of bundling OC Web to allow importing it as <script> tag.
9+
10+
- To use OC Web as an npm dependency, there are several options: `@opencensus/web-initial-load`
11+
to instrument with only the initial page load module, `@opencensus/web-instrumentation-zone`
12+
to instrument it with all the OC Web functionality plus the `Zone.js` library and
13+
`@opencensus/web-instrumentation-zone-peer-dep` also exports all the functionality but `Zone.js`
14+
is a peer dependency.
15+
716
## 0.0.3 - 2019-06-08
817

918
- Support custom end time for span (#95), thanks @skjindal93

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The script tag should go before the `</body>`. You will also need to set the
8787
trace sample rate via an `ocSampleRate` global variable as well.
8888
```html
8989
...
90-
<script src="https://unpkg.com/@opencensus/web-all@0.0.2/dist/initial-load-all.js"
90+
<script src="https://unpkg.com/@opencensus/web-scripts@0.0.3/dist/initial-load-all.js"
9191
integrity="sha384-VPY9XX7tiXeLekDPFXkfO2AqNpLTCNOzfXxVghzoVP05PXrG+wtHOW2kOP2ggO9o"
9292
async crossorigin="anonymous">
9393
</script>
@@ -105,16 +105,16 @@ trace sample rate via an `ocSampleRate` global variable as well.
105105

106106
You can also host the `initial-load-all.js` bundle from your own site. For
107107
docs on how to build the bundle see the
108-
[@opencensus/web-all readme][package-web-all].
108+
[@opencensus/web-scripts readme][package-web-scripts].
109109

110110
#### Using as NPM dependency in existing JS build
111111

112112
If you already have a JS build pipeline using e.g. webpack or similar, you can
113-
do `npm install @opencensus/web-all`, and then set the configuration variables
113+
do `npm install @opencensus/web-initial-load`, and then set the configuration variables
114114
and trigger the recording and exporting of the initial load spans as follows:
115115

116116
```js
117-
import { exportRootSpanAfterLoadEvent } from '@opencensus/web-all';
117+
import { exportRootSpanAfterLoadEvent } from '@opencensus/web-initial-load';
118118

119119
window.ocAgent = 'https://example.com/my-opencensus-agent-endpoint';
120120
window.ocSampleRate = 1.0; // Sample at 100% for test only. Default is 1/10000.
@@ -139,7 +139,7 @@ variable. The `traceparent` variable should be in the
139139

140140
```html
141141
...
142-
<script src="https://unpkg.com/@opencensus/web-all@0.0.2/dist/initial-load-all.js"
142+
<script src="https://unpkg.com/@opencensus/web-scripts@0.0.3/dist/initial-load-all.js"
143143
integrity="sha384-VPY9XX7tiXeLekDPFXkfO2AqNpLTCNOzfXxVghzoVP05PXrG+wtHOW2kOP2ggO9o"
144144
async crossorigin="anonymous">
145145
</script>
@@ -174,7 +174,7 @@ The OpenCensus web library is composed of the following packages:
174174
- **[@opencensus/web-propagation-tracecontext][package-web-propagation-tracecontext]**. This provides utilities to serialize and deserialize a `traceparent` trace context header in the [W3C draft trace context format][trace-context-url]
175175
- **[@opencensus/web-initial-load][package-web-initial-load]**. This package is in charge of generating the initial load page trace, plus the corresponding sampling decision for OpenCensus Web and
176176
storing a global initial load span context to be used by other packages.
177-
- **[@opencensus/web-all][package-web-all]**. This depends on all the other OpenCensus Web libraries and provides top-level functions for instrumenting the initial page load and exporting its spans to the OpenCensus Agent. It also provides WebPack builds for JS bundles that can be used in `<script>` tags.
177+
- **[@opencensus/web-scripts][package-web-scripts]**. This depends on all the other OpenCensus Web libraries and provides top-level functions for instrumenting the initial page load and exporting its spans to the OpenCensus Agent. It also provides WebPack builds for JS bundles that can be used in `<script>` tags.
178178

179179
## Useful links
180180
- For more information on OpenCensus, visit: <https://opencensus.io/>
@@ -224,7 +224,7 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
224224
[opencensus-node-url]: https://github.com/census-instrumentation/opencensus-node
225225
[opencensus-service-url]: https://github.com/census-instrumentation/opencensus-service
226226
[package-core]: https://github.com/census-instrumentation/opencensus-node/tree/master/packages/opencensus-core
227-
[package-web-all]: https://github.com/census-instrumentation/opencensus-web/tree/master/packages/opencensus-web-all
227+
[package-web-scripts]: https://github.com/census-instrumentation/opencensus-web/tree/master/packages/opencensus-web-scripts
228228
[package-web-core]: https://github.com/census-instrumentation/opencensus-web/tree/master/packages/opencensus-web-core
229229
[package-web-exporter-ocagent]: https://github.com/census-instrumentation/opencensus-web/tree/master/packages/opencensus-web-exporter-ocagent
230230
[package-web-initial-load]: https://github.com/census-instrumentation/opencensus-web/tree/master/packages/opencensus-web-initial-load

examples/initial_load/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ go run github.com/census-instrumentation/opencensus-service/cmd/ocagent
3838
### Step 2: Run the local webpack server
3939

4040
Then within your `opencensus-web` folder run the local webpack server for the
41-
`opencensus-all` package to serve the OpenCensus web scripts:
41+
`opencensus-scripts` package to serve the OpenCensus web scripts:
4242

4343
```bash
44-
cd packages/opencensus-web-all
44+
cd packages/opencensus-web-scripts
4545
npm run start:webpack-server
4646
```
4747

@@ -111,9 +111,9 @@ First build the OpenCensus Web scripts that will be deployed with the
111111
application:
112112

113113
```bash
114-
npm run build:prod --prefix=../../packages/opencensus-web-all
114+
npm run build:prod --prefix=../../packages/opencensus-web-scripts
115115
mkdir -p static
116-
cp ../../packages/opencensus-web-all/dist/*.js ./static
116+
cp ../../packages/opencensus-web-scripts/dist/*.js ./static
117117
```
118118
Then build the server container and push it to GCR:
119119

examples/user_interaction/client/package-lock.json

Lines changed: 0 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/user_interaction/client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"metrics"
1313
],
1414
"dependencies": {
15-
"@opencensus/web-all": "^0.0.3",
1615
"@opencensus/web-instrumentation-zone": "^0.0.3",
1716
"react": "^16.8.6",
1817
"react-dom": "^16.8.6",

examples/user_interaction/client/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import React from 'react';
18-
import { tracing } from '@opencensus/web-core';
18+
import { tracing } from '@opencensus/web-instrumentation-zone';
1919

2020
class App extends React.Component {
2121

examples/user_interaction/client/src/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import React from 'react';
1818
import ReactDOM from 'react-dom';
1919
import App from './App';
2020
import SecondPage from './SecondPage';
21-
import { exportRootSpanAfterLoadEvent } from '@opencensus/web-all';
22-
import { startInteractionTracker } from '@opencensus/web-instrumentation-zone';
21+
import { startTracing } from '@opencensus/web-instrumentation-zone';
2322

2423
import { Route, BrowserRouter as Router, Link } from 'react-router-dom'
2524

@@ -47,8 +46,4 @@ window.ocAgent = 'http://localhost:55678';
4746
window.ocTraceHeaderHostRegex = /.*/;
4847
window.ocSampleRate = 1.0; // Sample at 100% for test only. Default is 1/10000.
4948

50-
// Send the root span and child spans for the initial page load to the
51-
// OpenCensus agent if this request was sampled for trace.
52-
exportRootSpanAfterLoadEvent();
53-
54-
startInteractionTracker();
49+
startTracing();

package-lock.json

Lines changed: 10 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-web-all/codecov.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)