diff --git a/examples/tracer-web/.eslintrc b/examples/tracer-web/.eslintrc
index e2338e5e0..ab1862302 100644
--- a/examples/tracer-web/.eslintrc
+++ b/examples/tracer-web/.eslintrc
@@ -1,6 +1,6 @@
{
"env": {
- "node": true
+ "browser": true
},
"extends": "airbnb-base",
"parserOptions": {
@@ -11,6 +11,7 @@
"no-use-before-define": ["error", "nofunc"],
"no-console": "off",
"import/no-unresolved": "off",
- "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
+ "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
+ "import/no-extraneous-dependencies": [ "error", { "devDependencies": true } ]
}
}
diff --git a/examples/tracer-web/README.md b/examples/tracer-web/README.md
index a8d3f76fd..e7947d135 100644
--- a/examples/tracer-web/README.md
+++ b/examples/tracer-web/README.md
@@ -18,10 +18,33 @@ npm start
By default, the application will run on port `8090`.
+Other options for running the application, this serves the same examples using different source file processing so you can review the different effects on the resulting bundle sizes that are loaded via the browser.
+
+| Command | Description
+|---------|------------
+| `npm start` (Default) | Serve the raw development bundles compressed via GZip
+| `npm run start-nc` | Serve the raw development bundles uncompressed
+| `npm run start-prod` | Serve the minified production bundles compressed via GZip
+| `npm run start-prodnc` | Serve the minified production bundles uncompressed
+
+The development modes includes source maps via the webpack devtool `eval-source-map` mode which substantially increases the size of the bundles.
+
## Examples
+The examples includes several variants so that you can see how to mix and match individual components and the impact this can have on the resulting bundle size.
+
### XMLHttpRequest
+This example shows how to use the XMLHttpRequest Instrumentation with the OTLP Trace exporter and with the B3 Propagator.
+
+Included Components
+
+- XMLHttpRequestInstrumentation
+- ZoneContextManager
+- OTLPTraceExporter
+- WebTracerProvider
+- B3Propagator
+
To see the results, open the browser at and make sure you have the browser console open. The application is using the `ConsoleSpanExporter` and will post the created spans to the browser console.
The screen will look as follows:
@@ -29,8 +52,63 @@ The screen will look as follows:
### Fetch
+This example shows how to use the Fetch Instrumentation with the OTLP Trace exporter and with the B3 Propagator.
+
+Included Components
+
+- FetchInstrumentation
+- ZoneContextManager
+- OTLPTraceExporter
+- WebTracerProvider
+- B3Propagator
+
To see the results, open the browser at and make sure you have the browser console open. The application is using the `ConsoleSpanExporter` and will post the created spans to the browser console.
+### FetchXhr
+
+This example shows how to use both the XMLHttpRequest and Fetch Instrumentations with the OTLP Trace exporter but without the B3 Propagator.
+
+Included Components
+
+- XMLHttpRequestInstrumentation
+- FetchInstrumentation
+- ZoneContextManager
+- OTLPTraceExporter
+- WebTracerProvider
+
+### FetchXhrB3
+
+This example shows how to use both the XMLHttpRequest and Fetch Instrumentations with the OTLP Trace exporter and with the B3 Propagator
+
+Included Components
+
+- XMLHttpRequestInstrumentation
+- FetchInstrumentation
+- ZoneContextManager
+- OTLPTraceExporter
+- WebTracerProvider
+- B3Propagator
+
+### Metrics
+
+This example shows how to use the OTLP Metric Exporter, it does not include the Trace Exporter. Does not include traces
+
+Included Components
+
+- OTLPMetricExporter
+- MeterProvider
+- Resource
+- SemanticResourceAttributes
+
+### Zipkin
+
+This example show a simple usage of the ZipKin Exporter with the Web Tracer Provider
+
+Included Components
+
+- WebTracerProvider
+- ZipkinExporter
+
## Useful links
- For more information on OpenTelemetry, visit:
diff --git a/examples/tracer-web/examples/fetch/index.js b/examples/tracer-web/examples/fetch/index.js
index 689a119af..2871c98cd 100644
--- a/examples/tracer-web/examples/fetch/index.js
+++ b/examples/tracer-web/examples/fetch/index.js
@@ -1,7 +1,6 @@
-'use strict';
import { context, trace } from '@opentelemetry/api';
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
-import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
+import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
import { ZoneContextManager } from '@opentelemetry/context-zone';
@@ -9,6 +8,10 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
const provider = new WebTracerProvider();
+
+// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
+// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
+// exporter without delay
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));
provider.register({
@@ -34,7 +37,7 @@ const webTracerWithZone = provider.getTracer('example-tracer-web');
const getData = (url) => fetch(url, {
method: 'GET',
headers: {
- 'Accept': 'application/json',
+ Accept: 'application/json',
'Content-Type': 'application/json',
},
});
@@ -46,7 +49,7 @@ const prepareClickEvent = () => {
const element = document.getElementById('button1');
const onClick = () => {
- const singleSpan = webTracerWithZone.startSpan(`files-series-info`);
+ const singleSpan = webTracerWithZone.startSpan('files-series-info');
context.with(trace.setSpan(context.active(), singleSpan), () => {
getData(url).then((_data) => {
trace.getSpan(context.active()).addEvent('fetching-single-span-completed');
diff --git a/examples/tracer-web/examples/fetchXhr/index.html b/examples/tracer-web/examples/fetchXhr/index.html
new file mode 100644
index 000000000..841d5ee3e
--- /dev/null
+++ b/examples/tracer-web/examples/fetchXhr/index.html
@@ -0,0 +1,20 @@
+
+
+
+