Skip to content

Commit

Permalink
fix: address multiple PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MSNev committed Dec 14, 2021
1 parent a4bd541 commit 3205e9b
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 44 deletions.
5 changes: 3 additions & 2 deletions examples/tracer-web/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"env": {
"node": true
"browser": true
},
"extends": "airbnb-base",
"parserOptions": {
Expand All @@ -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 } ]
}
}
7 changes: 4 additions & 3 deletions examples/tracer-web/examples/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,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({
Expand All @@ -30,7 +34,6 @@ registerInstrumentations({

const webTracerWithZone = provider.getTracer('example-tracer-web');

// eslint-disable-next-line no-undef
const getData = (url) => fetch(url, {
method: 'GET',
headers: {
Expand All @@ -43,7 +46,6 @@ const getData = (url) => fetch(url, {
const prepareClickEvent = () => {
const url = 'https://httpbin.org/get';

// eslint-disable-next-line no-undef
const element = document.getElementById('button1');

const onClick = () => {
Expand All @@ -67,5 +69,4 @@ const prepareClickEvent = () => {
element.addEventListener('click', onClick);
};

// eslint-disable-next-line no-undef
window.addEventListener('load', prepareClickEvent);
15 changes: 4 additions & 11 deletions examples/tracer-web/examples/fetchXhr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { ZoneContextManager } from '@opentelemetry/context-zone';
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({
Expand All @@ -24,11 +28,6 @@ registerInstrumentations({
],
clearTimingResources: true,
}),
],
});

registerInstrumentations({
instrumentations: [
new XMLHttpRequestInstrumentation({
ignoreUrls: [/localhost:8090\/sockjs-node/],
propagateTraceHeaderCorsUrls: [
Expand All @@ -40,7 +39,6 @@ registerInstrumentations({

const webTracerWithZone = provider.getTracer('example-tracer-web');

// eslint-disable-next-line no-undef
const getData = (url) => fetch(url, {
method: 'GET',
headers: {
Expand All @@ -50,7 +48,6 @@ const getData = (url) => fetch(url, {
});

const getDataXhr = (url) => new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
const req = new XMLHttpRequest();
req.open('GET', url, true);
req.setRequestHeader('Content-Type', 'application/json');
Expand All @@ -68,10 +65,7 @@ const getDataXhr = (url) => new Promise((resolve, reject) => {
const prepareClickEvent = () => {
const url = 'https://httpbin.org/get';

// eslint-disable-next-line no-undef
const element1 = document.getElementById('button1');

// eslint-disable-next-line no-undef
const element2 = document.getElementById('button2');

const clickHandler = (fetchFn) => () => {
Expand All @@ -96,5 +90,4 @@ const prepareClickEvent = () => {
element2.addEventListener('click', clickHandler(getDataXhr));
};

// eslint-disable-next-line no-undef
window.addEventListener('load', prepareClickEvent);
15 changes: 4 additions & 11 deletions examples/tracer-web/examples/fetchXhrB3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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({
Expand All @@ -26,11 +30,6 @@ registerInstrumentations({
],
clearTimingResources: true,
}),
],
});

registerInstrumentations({
instrumentations: [
new XMLHttpRequestInstrumentation({
ignoreUrls: [/localhost:8090\/sockjs-node/],
propagateTraceHeaderCorsUrls: [
Expand All @@ -42,7 +41,6 @@ registerInstrumentations({

const webTracerWithZone = provider.getTracer('example-tracer-web');

// eslint-disable-next-line no-undef
const getData = (url) => fetch(url, {
method: 'GET',
headers: {
Expand All @@ -52,7 +50,6 @@ const getData = (url) => fetch(url, {
});

const getDataXhr = (url) => new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
const req = new XMLHttpRequest();
req.open('GET', url, true);
req.setRequestHeader('Content-Type', 'application/json');
Expand All @@ -70,10 +67,7 @@ const getDataXhr = (url) => new Promise((resolve, reject) => {
const prepareClickEvent = () => {
const url = 'https://httpbin.org/get';

// eslint-disable-next-line no-undef
const element1 = document.getElementById('button1');

// eslint-disable-next-line no-undef
const element2 = document.getElementById('button2');

const clickHandler = (fetchFn) => () => {
Expand All @@ -98,5 +92,4 @@ const prepareClickEvent = () => {
element2.addEventListener('click', clickHandler(getDataXhr));
};

// eslint-disable-next-line no-undef
window.addEventListener('load', prepareClickEvent);
3 changes: 0 additions & 3 deletions examples/tracer-web/examples/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ function startMetrics() {
}

const addClickEvents = () => {
// eslint-disable-next-line no-undef
const startBtn = document.getElementById('startBtn');

// eslint-disable-next-line no-undef
const stopBtn = document.getElementById('stopBtn');
startBtn.addEventListener('click', startMetrics);
stopBtn.addEventListener('click', stopMetrics);
};

// eslint-disable-next-line no-undef
window.addEventListener('load', addClickEvents);
7 changes: 4 additions & 3 deletions examples/tracer-web/examples/xml-http-request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { registerInstrumentations } from '@opentelemetry/instrumentation';

const providerWithZone = 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
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));

Expand All @@ -30,7 +34,6 @@ registerInstrumentations({
const webTracerWithZone = providerWithZone.getTracer('example-tracer-web');

const getData = (url) => new Promise((resolve, reject) => {
// eslint-disable-next-line no-undef
const req = new XMLHttpRequest();
req.open('GET', url, true);
req.setRequestHeader('Content-Type', 'application/json');
Expand All @@ -48,7 +51,6 @@ const getData = (url) => new Promise((resolve, reject) => {
const prepareClickEvent = () => {
const url1 = 'https://httpbin.org/get';

// eslint-disable-next-line no-undef
const element = document.getElementById('button1');

const onClick = () => {
Expand All @@ -68,5 +70,4 @@ const prepareClickEvent = () => {
element.addEventListener('click', onClick);
};

// eslint-disable-next-line no-undef
window.addEventListener('load', prepareClickEvent);
2 changes: 0 additions & 2 deletions examples/tracer-web/examples/zipkin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ provider.register();
const tracer = provider.getTracer('example-tracer-web');

const prepareClickEvent = () => {
// eslint-disable-next-line no-undef
const element = document.getElementById('button1');

const onClick = () => {
Expand All @@ -28,5 +27,4 @@ const prepareClickEvent = () => {
element.addEventListener('click', onClick);
};

// eslint-disable-next-line no-undef
window.addEventListener('load', prepareClickEvent);
10 changes: 5 additions & 5 deletions examples/tracer-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
"@opentelemetry/core": "^1.0.1",
"@opentelemetry/sdk-trace-base": "^1.0.1",
"@opentelemetry/sdk-trace-web": "^1.0.1",
"@opentelemetry/exporter-zipkin": "^1.0.1",
"@opentelemetry/semantic-conventions": "^1.0.1",
"@opentelemetry/propagator-b3": "^1.0.1",
"@opentelemetry/resources": "^1.0.1",
"@opentelemetry/instrumentation": "0.27.0",
"@opentelemetry/instrumentation-fetch": "0.27.0",
"@opentelemetry/instrumentation-xml-http-request": "0.27.0",
"@opentelemetry/exporter-trace-otlp-http": "0.27.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.27.0",
"@opentelemetry/exporter-zipkin": "1.0.1",
"@opentelemetry/sdk-metrics-base": "0.27.0",
"@opentelemetry/semantic-conventions": "^1.0.1",
"@opentelemetry/propagator-b3": "1.0.1",
"@opentelemetry/resources": "^1.0.1"
"@opentelemetry/sdk-metrics-base": "0.27.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme"
}
2 changes: 0 additions & 2 deletions examples/tracer-web/webpack.dev.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const webpack = require('webpack');
// eslint-disable-next-line import/no-extraneous-dependencies
const webpackMerge = require('webpack-merge');
const path = require('path');

Expand Down
2 changes: 0 additions & 2 deletions examples/tracer-web/webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const webpack = require('webpack');
// eslint-disable-next-line import/no-extraneous-dependencies
const webpackMerge = require('webpack-merge');
const path = require('path');

Expand Down

0 comments on commit 3205e9b

Please sign in to comment.